Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force lowercase headers and force uppercase method #54

Merged
merged 1 commit into from
May 2, 2024

Conversation

eyJhb
Copy link
Contributor

@eyJhb eyJhb commented Jan 5, 2023

Fixes issue #53 as well as forcing methods to be uppercase.
Comments are welcome!

@dydek
Copy link

dydek commented Apr 2, 2023

Hi @eyJhb , I've found the same issue lately ( eg using JS fetch with custom headers gives you the mixed headers with title and lowercase style) - Don't you think that the method https://github.com/belyalov/tinyweb/blob/master/tinyweb/server.py#L134 should also be changed? I solved the issue differently, by using the same ( and consistent ) lower-cased headers names ( eg in the method mentioned above ) across the source code and changing the https://github.com/belyalov/tinyweb/blob/master/tinyweb/server.py#L99 to provide also lowercased headers.

I can help write some additional tests to ensure everything is working as expected with all the needed cases, but I'm not so sure if @belyalov still maintains this project.

@richardcockerill
Copy link

richardcockerill commented Apr 16, 2024

I experienced a variation on this problem too regarding Content-Length and Content-Type on PUT and POST requests when using vite development server while developing a client side frontend with a tinyweb backend. The vite dev server proxy mutated the headers to lower case before forwarding to my tiny web backend and the headers failed to match and the request bodies were not read. I had to fix the string literals at https://github.com/belyalov/tinyweb/blob/master/tinyweb/server.py#L134 and https://github.com/belyalov/tinyweb/blob/master/tinyweb/server.py#L137 too

Worthing noting that the http standard says that head fields names are case insensitive https://datatracker.ietf.org/doc/html/rfc1945#section-4.2

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

@eyJhb
Copy link
Contributor Author

eyJhb commented May 2, 2024

@FabianClemenz any chance this could be merged?

@belyalov belyalov merged commit b4393ac into belyalov:master May 2, 2024
@belyalov
Copy link
Owner

belyalov commented May 2, 2024

Thanks, it makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants