Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Content-Type header is parsed incorrectly #2540

Closed
tarampampam opened this issue Mar 16, 2024 · 1 comment
Closed

The Content-Type header is parsed incorrectly #2540

tarampampam opened this issue Mar 16, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@tarampampam
Copy link

The HTTP response header Content-Type is in the following format:

Content-Type: text/plain; version=0.0.4; charset=utf-8; escaping=values

This header is generated by the Go Prometheus metrics package

Makes hurl using impossible:

./test/hurl/metrics.hurl: Running [7/10]
error: Invalid charset
  --> ./test/hurl/metrics.hurl:7:1
   |
 7 | body contains "http_requests_duration_millisecond"
   | ^^^^ the charset 'utf-8; escaping=values' is not valid
   |

Steps to reproduce

$ curl -v http://127.0.0.1:8080/metrics

*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Sat, 16 Mar 2024 16:28:14 GMT
< Content-Type: text/plain; version=0.0.4; charset=utf-8; escaping=values
< Content-Length: 2220
< 
# HELP http_requests_duration_milliseconds Histogram of the time (in milliseconds) each request took.
# TYPE http_requests_duration_milliseconds histogram
http_requests_duration_milliseconds_bucket{le="0.001"} 5
http_requests_duration_milliseconds_bucket{le="0.003"} 5
http_requests_duration_milliseconds_bucket{le="0.005"} 5
http_requests_duration_milliseconds_bucket{le="0.01"} 5
http_requests_duration_milliseconds_bucket{le="0.025"} 5
http_requests_duration_milliseconds_bucket{le="0.05"} 5
http_requests_duration_milliseconds_bucket{le="0.1"} 5
http_requests_duration_milliseconds_bucket{le="0.25"} 5
http_requests_duration_milliseconds_bucket{le="0.5"} 5
http_requests_duration_milliseconds_bucket{le="1"} 5
http_requests_duration_milliseconds_bucket{le="2.5"} 5
http_requests_duration_milliseconds_bucket{le="5"} 5
http_requests_duration_milliseconds_bucket{le="10"} 5
http_requests_duration_milliseconds_bucket{le="+Inf"} 5
http_requests_duration_milliseconds_sum 0.000402213
http_requests_duration_milliseconds_count 5
# HELP http_requests_total_count Counter of HTTP requests made.
# TYPE http_requests_total_count counter
http_requests_total_count 5
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.01
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 8
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.3500416e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.71060647785e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1.806196736e+09
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
* Connection #0 to host 127.0.0.1 left intact

metrics.hurl:

GET http://127.0.0.1:8080/metrics

HTTP 200

[Asserts]
header "Content-Type" contains "text/plain"
body contains "http_requests_duration_millisecond"
body contains "http_requests_total_count"

What is the expected correct behavior?

Asserts should pass without any errors.

Execution context

  • Hurl Version (hurl --version): 4.2.0

Possible fixes

Read the charset value from charset= to (;|$), not to $

@tarampampam tarampampam added the bug Something isn't working label Mar 16, 2024
@jcamiel
Copy link
Collaborator

jcamiel commented Mar 16, 2024

Hi @tarampampam

It's indeed a bug in the charset parsing logic, thanks for your report,

@jcamiel jcamiel added this to the 4.3.0 milestone Mar 17, 2024
@jcamiel jcamiel linked a pull request Mar 17, 2024 that will close this issue
@jcamiel jcamiel closed this as completed Mar 17, 2024
@jcamiel jcamiel self-assigned this Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants