Localstack: `generic_proxy.py`'s `Connection` header handling should be case insensitive

Created on 30 Apr 2020  路  3Comments  路  Source: localstack/localstack

Type of request:

  • [x] bug report
  • [ ] feature request

Detailed description

In 0.10.8, localstack/services/generic_proxy.py has regressed with respect to Connection header handling. HTTP headers are expected to be case insensitive.

In version 0.10.7 of generic_proxy.py:

if forward_headers.get('Connection', '').lower() != 'keep-alive':
  self.close_connection = 1

in 0.10.8 this was changed to

if forward_headers.get('Connection') not in ['keep-alive', None]:
  self.close_connection = 1

Note that the call to lower() was removed.

Expected behavior

Keep case insensitive Connection header handling.

Actual behavior

Case sensitive

Steps to reproduce

Send a request with Connection: Keep-Alive

Command used to start LocalStack

N/A

Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

N/A

Most helpful comment

Thanks for reporting @bobtiernay-okta . This should be fixed in #2377 - can you please give it a try with the latest version of the Docker image? Please report here if the problem persists. Thanks!

All 3 comments

Thanks for reporting @bobtiernay-okta . This should be fixed in #2377 - can you please give it a try with the latest version of the Docker image? Please report here if the problem persists. Thanks!

@whummer I'm wondering about the logic:

        connection_header = forward_headers.get('Connection') or ''
        if connection_header.lower() not in ['keep-alive', '']:
            self.close_connection = 1

Why are 'keep-alive', '' and None treated the same? Shouldn't this logic be the following instead?

if forward_headers.get('Connection', '').lower() == 'close':
            self.close_connection = 1

or

if forward_headers.get('Connection', '').lower() != 'keep-alive':
            self.close_connection = 1

?

@whummer Per your ask, I've validated the fix and it looks like it does help quite a bit with our vast set of integration tests that invoke LocalStack in parallel. I have a feeling a number of reported issues will benefit from these (at least those using the Java AWS SDK). Looking forward to the next release so that we can move forward from 0.10.7.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simonDeHero picture simonDeHero  路  3Comments

holotrek picture holotrek  路  3Comments

burm87 picture burm87  路  3Comments

JoeReid picture JoeReid  路  3Comments

7seven7lst picture 7seven7lst  路  3Comments