Add header normalization and fetching for hosting service HTTP support.

Review Request #11199 — Created Sept. 24, 2020 and submitted

Information

Review Board
release-4.0.x

Reviewers

We've had some annoyances with properly looking up headers from an HTTP
response in hosting service implementations in a consistent manner
across versions of Review Board, and across versions of Python. Work has
been done to fix this for GitHub, where this was more immediately
noticed.

This change works to standardize how we store headers, both for requests
and responses, in the new hosting service HTTP implementation. We now
store all headers as lowercase, and normalize on lookup.

HostingServiceHTTPResponse now has a get_header() method, just like
HostingServiceHTTPRequest. This is now preferred over accessing
headers directly, and will handle normalization on the caller's
behalf. This is future-proof and avoids any further confusion around
headers.

Unit tests pass on Python 2.7 and 3.6 through 3.8.

Summary ID
Add header normalization and fetching for hosting service HTTP support.
We've had some annoyances with properly looking up headers from an HTTP response in hosting service implementations in a consistent manner across versions of Review Board, and across versions of Python. Work has been done to fix this for GitHub, where this was more immediately noticed. This change works to standardize how we store headers, both for requests and responses, in the new hosting service HTTP implementation. We now store all headers as lowercase, and normalize on lookup. `HostingServiceHTTPResponse` now has a `get_header()` method, just like `HostingServiceHTTPRequest`. This is now preferred over accessing `headers` directly, and will handle normalization on the caller's behalf. This is future-proof and avoids any further confusion around headers.
cecbe12e21956ad0351290633edbbbbfd5b0f51a
Description From Last Updated

E501 line too long (82 > 79 characters)

reviewbotreviewbot

The first and third Authorization header tests are the same test. The Content-length header tests are the same too. Let …

hailanhailan
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
hailan
  1. Great work!

  2. reviewboard/hostingsvcs/tests/test_client.py (Diff revision 2)
     
     
     
     
     
     
     
     
    Show all issues

    The first and third Authorization header tests are the same test.
    The Content-length header tests are the same too.
    Let me know if this is done on purpose.

    1. Oops, definitely not! They were supposed to be lowercased. I did something wrong for sure. Good catch!

    2. That is, the 3rd one was supposed to be lowercase. The 2nd was supposed to be all caps.

  3. 
      
chipx86
hailan
  1. Ship It!
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (0a3bde5)
Loading...