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

error parsing response headers #25

Open
Nytelife26 opened this issue Jun 24, 2024 · 0 comments · May be fixed by #26
Open

error parsing response headers #25

Nytelife26 opened this issue Jun 24, 2024 · 0 comments · May be fixed by #26

Comments

@Nytelife26
Copy link
Contributor

It would appear Cloudflare has added a server-timing entry, as well as Server-Timing, to their response headers.
image
This is silly because headers are case insensitive, and causes the following issue.

cfRequestDuration;dur=47.999859, cfL4;desc="?proto=TCP&rtt=9805&sent=10&recv=9&lost=0&retrans=0&sent_bytes=6393&recv_bytes=961&delivery_rate=603344&cwnd=190&unsent_bytes=0&cid=91730a7c5440994f&ts=93"
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/nytelife26/projects/cloudflarepycli/cfspeedtest/__main__.py", line 47, in <module>
    cfspeedtest()
  File "/home/nytelife26/projects/cloudflarepycli/cfspeedtest/__main__.py", line 39, in cfspeedtest
    results = CloudflareSpeedtest().run_all()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nytelife26/projects/cloudflarepycli/cfspeedtest/cloudflare.py", line 270, in run_all
    self.run_test_latency(test)
  File "/home/nytelife26/projects/cloudflarepycli/cfspeedtest/cloudflare.py", line 244, in run_test_latency
    timers = self.run_test(test)
             ^^^^^^^^^^^^^^^^^^^
  File "/home/nytelife26/projects/cloudflarepycli/cfspeedtest/cloudflare.py", line 235, in run_test
    float(r.headers["Server-Timing"].split("=")[1]) / 1e3
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '47.999859, cfL4;desc'

Since they're case insensitive, it looks like requests is merging them, which breaks our parsing.

@Nytelife26 Nytelife26 linked a pull request Jun 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant