Skip to content

Commit 7d41a2d

Browse files
committed
feat: add global 'Server: Pingclair' identification header 🦀🏷️
1 parent d97731e commit 7d41a2d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pingclair-proxy/src/server.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,15 @@ impl PingclairProxy {
340340
}
341341
let body_bytes = body.as_deref().unwrap_or("").as_bytes();
342342
resp.insert_header("Content-Length", body_bytes.len().to_string()).unwrap();
343+
resp.insert_header("Server", "Pingclair").unwrap();
343344
session.write_response_header(Box::new(resp), false).await?;
344345
session.write_response_body(Some(Bytes::copy_from_slice(body_bytes)), true).await?;
345346
Ok(true)
346347
}
347348
HandlerConfig::Redirect { to, code } => {
348349
let mut resp = ResponseHeader::build(*code, Some(3)).unwrap();
349350
resp.insert_header("Location", to.as_str()).unwrap();
351+
resp.insert_header("Server", "Pingclair").unwrap();
350352
session.write_response_header(Box::new(resp), true).await?;
351353
Ok(true)
352354
}
@@ -381,6 +383,7 @@ impl PingclairProxy {
381383
header.insert_header("Content-Encoding", encoding.as_str()).unwrap();
382384
}
383385
header.insert_header("Accept-Ranges", "bytes").unwrap();
386+
header.insert_header("Server", "Pingclair").unwrap();
384387

385388
session.write_response_header(Box::new(header), false).await?;
386389
session.write_response_body(Some(Bytes::from(file.content)), true).await?;
@@ -510,6 +513,7 @@ impl ProxyHttp for PingclairProxy {
510513
if cl > limit {
511514
let mut header = pingora_http::ResponseHeader::build(413, Some(4)).unwrap();
512515
header.insert_header("Connection", "close").unwrap();
516+
header.insert_header("Server", "Pingclair").unwrap();
513517
session.write_response_header(Box::new(header), true).await?;
514518
return Ok(true);
515519
}
@@ -538,6 +542,7 @@ impl ProxyHttp for PingclairProxy {
538542
}
539543
}
540544
}
545+
header.insert_header("Server", "Pingclair").unwrap();
541546
session.write_response_header(Box::new(header), true).await?;
542547
return Ok(true);
543548
}

0 commit comments

Comments
 (0)