Skip to content

Commit

Permalink
http_server: Correct description of header injection behavior with co…
Browse files Browse the repository at this point in the history
…nflicting fields
  • Loading branch information
jblazquez committed Nov 2, 2024
1 parent 43f474f commit 0bf233c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/sources/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct SimpleHttpConfig {
///
/// Specifying "*" results in all headers included in the log event.
///
/// These override any values included in the JSON payload with conflicting names.

This comment has been minimized.

Copy link
@jblazquez

jblazquez Nov 2, 2024

Author Contributor

I think this was probably copy-pasted from the description of query_parameters, even though the behavior was different.

/// These headers are not included in the JSON payload if a field with a conflicting name exists.
#[serde(default)]
#[configurable(metadata(docs::examples = "User-Agent"))]
#[configurable(metadata(docs::examples = "X-My-Custom-Header"))]
Expand Down Expand Up @@ -1084,6 +1084,8 @@ mod tests {
let mut headers = HeaderMap::new();
headers.insert("User-Agent", "test_client".parse().unwrap());
headers.insert("X-Case-Sensitive-Value", "CaseSensitive".parse().unwrap());
// Header that conflicts with an existing field.
headers.insert("key1", "value_from_header".parse().unwrap());

let (rx, addr) = source(
vec!["*".to_string()],
Expand Down Expand Up @@ -1183,7 +1185,11 @@ mod tests {
.await;

spawn_ok_collect_n(
send_with_query(addr, "{\"key1\":\"value1\"}", "source=staging&region=gb"),
send_with_query(
addr,
"{\"key1\":\"value1\",\"key2\":\"value2\"}",
"source=staging&region=gb&key1=value_from_query",
),
rx,
1,
)
Expand All @@ -1194,7 +1200,8 @@ mod tests {
{
let event = events.remove(0);
let log = event.as_log();
assert_eq!(log["key1"], "value1".into());
assert_eq!(log["key1"], "value_from_query".into());
assert_eq!(log["key2"], "value2".into());
assert_eq!(log["source"], "staging".into());
assert_eq!(log["region"], "gb".into());
assert_event_metadata(log).await;
Expand Down
2 changes: 1 addition & 1 deletion src/sources/opentelemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct HttpConfig {
///
/// Specifying "*" results in all headers included in the log event.
///
/// These override any values included in the JSON payload with conflicting names.
/// These headers are not included in the JSON payload if a field with a conflicting name exists.
#[serde(default)]
#[configurable(metadata(docs::examples = "User-Agent"))]
#[configurable(metadata(docs::examples = "X-My-Custom-Header"))]
Expand Down
2 changes: 1 addition & 1 deletion website/cue/reference/components/sources/base/http.cue
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ base: components: sources: http: configuration: {
Specifying "*" results in all headers included in the log event.
These override any values included in the JSON payload with conflicting names.
These headers are not included in the JSON payload if a field with a conflicting name exists.
"""
required: false
type: array: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ base: components: sources: http_server: configuration: {
Specifying "*" results in all headers included in the log event.
These override any values included in the JSON payload with conflicting names.
These headers are not included in the JSON payload if a field with a conflicting name exists.
"""
required: false
type: array: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ base: components: sources: opentelemetry: configuration: {
Specifying "*" results in all headers included in the log event.
These headers are not included in the JSON payload if field with conflicting names exists.
These headers are not included in the JSON payload if a field with a conflicting name exists.
"""
required: false
type: array: {
Expand Down

0 comments on commit 0bf233c

Please sign in to comment.