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

Content-Type is always set #457

Closed
chrisseto opened this issue Aug 3, 2015 · 12 comments
Closed

Content-Type is always set #457

chrisseto opened this issue Aug 3, 2015 · 12 comments
Labels
Milestone

Comments

@chrisseto
Copy link

As of 089e829 the Content-Type header is alway set if not otherwise set by the user.
This behavior is often undesirable and should be opt-in or at least provide an option to opt-out.
In the case of using Amazon S3's signed URLs, extra steps must be taken to have this header included.

@asvetlov
Copy link
Member

asvetlov commented Aug 3, 2015

When you send request you know content type, isn't it?

As an option we may add ignore_default_headers parameter for client API (both for ClientSession and request).

What's your use case? Why S3's signed URLs are not aware about content type?

@jettify
Copy link
Member

jettify commented Aug 4, 2015

As far as I remember issues with s3 is following: s3 api requires special signature to be added, when you preparing request. So you take body and headers then calculate signature, but content-type header is not present on that time, it will be added when you actually send request. For my botocore port I just added content-type explicitly https://github.com/jettify/aiobotocore/blob/master/aiobotocore/endpoint.py#L87-L98

@asvetlov
Copy link
Member

asvetlov commented Aug 4, 2015

Well, ignore_default_headers (maybe better name?) looks a good idea.

@chrisseto
Copy link
Author

@jettify That would work but I'm not certain how that would affect amazon's own content type detection
@asvetlov I like the idea of ignore_default_headers but how far would that extend? Some that are automatically added are fairly helpful, ie User-Agent.

@jettify
Copy link
Member

jettify commented Aug 5, 2015

@chrisseto I tested my implementation with almost all tests (except pagination) of botocore library and it works as expected.

@asvetlov
Copy link
Member

asvetlov commented Aug 5, 2015

See also #379

@asvetlov
Copy link
Member

asvetlov commented Aug 5, 2015

@chrisseto we don't autoset User-Agent. But you may setup default user-agent header with ClientSession:

session = ClientSession(headers={'User-Agent': 'aiohttp client 0.17'})

@chrisseto
Copy link
Author

Using aiohttp.request, on version 0.14.1, it seems to set it.

In [5]: aiohttp.__version__
Out[5]: '0.14.1'

In [6]: asyncio.get_event_loop().run_until_complete(aiohttp.request('GET', 'http://localhost:1234'))
~❯❯❯ nc -l 1234
GET / HTTP/1.1
ACCEPT: */*
ACCEPT-ENCODING: gzip, deflate
HOST: localhost:1234
CONTENT-LENGTH: 0
CONNECTION: keep-alive
USER-AGENT: Python/3.4 aiohttp/0.14.1

@asvetlov
Copy link
Member

asvetlov commented Aug 5, 2015

Ahh, got it. Sorry.

@mpaolini
Copy link
Contributor

for User-Agent you can now use skip_auto_headers={'USER-AGENT'} and as of pull request #507 this same method works for Content-Type too

@mpaolini
Copy link
Contributor

I think we can close this one

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants