Skip to content

error parsing response headers #25

@Nytelife26

Description

@Nytelife26

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions