Giter Site home page Giter Site logo

Header case-sensitivity? about vcrpy HOT 6 CLOSED

kevin1024 avatar kevin1024 commented on May 17, 2024
Header case-sensitivity?

from vcrpy.

Comments (6)

kevin1024 avatar kevin1024 commented on May 17, 2024

Is this a bug?

Afraid not.

From RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", paragraph 4.2, "Message Headers":

Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.

from vcrpy.

kevin1024 avatar kevin1024 commented on May 17, 2024

It occurs to me when rereading this I may have misunderstood your issue, in which case feel free to reopen with some code to reproduce the issue.

from vcrpy.

hartsock avatar hartsock commented on May 17, 2024

I have a unique server that transmits set-cookie in all lower case as the header field, after doing some research, it looks like the bug is on the server not the client ... since the standard is Set-Cookie as described in documentation. I only notice this in test because some how the case gets fixed in VCRpy.

Edit:
The phrase set-cookie (all lower case) only occurs once in documentation rfc2109 ...

EDIT 2:
Note documentation....

Attributes (names) (attr) are case-insensitive. White space is
permitted between tokens. Note that while the above syntax
description shows value as optional, most attrs require them.

I think this means values such as set-cookie and Set-Cookie should be treated the same. This source thinks so tracing the source...

http/client.py#L755
headers.py#L90

It looks like at least one version of getheader may be case insensitive.

from vcrpy.

kevin1024 avatar kevin1024 commented on May 17, 2024

Yeah, VCR is treating headers as case-insensitive (in accordance with RFC2616) and is normalizing them (by lowercasing them) before storing them in the cassette. That's why it's "fixing" the problem for you.

from vcrpy.

hartsock avatar hartsock commented on May 17, 2024

I wrote a test that's currently failing to illustrate why this might be an issue: hartsock@a86a3f7 ... I'm not 100% certain what the correct behavior should be in this circumstance but it looks like based on the headers.py#L90 reference above vcrpy might need to lower case the name used with getheader.

from vcrpy.

kevin1024 avatar kevin1024 commented on May 17, 2024

I think you're right. I'll try to look into it more this weekend, but I would like VCR to be as transparent as possible when patching out httplib, including the behavior of getheader().

On Aug 1, 2014, at 12:14 PM, Shawn Hartsock [email protected] wrote:

I wrote a test that's currently failing to illustrate why this might be an issue: hartsock/vcrpy@a86a3f7 ... I'm not 100% certain what the correct behavior should be in this circumstance but it looks like based on the headers.py#L90 reference above vcrpy might need to lower case the name used with getheader.


Reply to this email directly or view it on GitHub.

from vcrpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.