Add header normalization and fetching for hosting service HTTP support.

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

chipx86
Review Board
release-4.0.x
11200
reviewboard

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
Add header normalization and fetching for hosting service HTTP support.
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)
     
     
     
     
     
     
     
     

    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
Review request changed

Change Summary:

Fixed some bad variations on HTTP headers in the unit tests.

Commits:

Summary
-
Add header normalization and fetching for hosting service HTTP support.
+
Add header normalization and fetching for hosting service HTTP support.

Diff:

Revision 3 (+168 -22)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
hailan
  1. Ship It!
  2. 
      
david
  1. Ship It!
  2. 
      
Loading...