-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
deprecate content_type
argument
#675
Comments
Please don't. It's nice 'syntactic sugar' for what's probably most common header. It also makes moving from httpretty much more straightforward. |
At least for the responses recorder having the separate content-type causes some difficulty. The recorder does not set the 'content-type' parameter when it saves a real http payload as a Response. This means Response.init sets the 'content-type' attribute value to 'text/plain' in every case. The recorder actually strips out the content-type http header (among others) and when the Response is written to the out.yaml file the Response.content-type is all you get and that is of course always 'text/plain'. So when you load the output file into the responses registry the mocked Response does not necessarily have the same content-type header value as the original and some libraries process responses differently depending on the content-type header value. As an example: https://github.com/python-gitlab/python-gitlab/blob/main/gitlab/client.py#L832 I've mad a stab at sorting this out for the recorder in #728 but it definitely made me wonder why it was done this way in the first place. It seems like at least the Response init should set its 'content-type' attribute from the input headers if it is there and only fallback to setting it to 'text/plain' when no value is given. But there is surely some historical context I am missing. |
Should we consider deprecating the
content_type
argument?It appears redundant in conjunction with the
headers
argument. Common tools like cURL and libraries such asrequests
do not provide a specific way to set the data type; it is typically managed through headers. Therefore, I propose that we consider deprecating thecontent_type
argument to streamline the function signature and simplify the codebase. Instead, we could encourage users to utilize theheaders
parameter for specifying the content type. This would enhance clarity and maintain consistency with prevailing practices.@markstory
thoughts?
The text was updated successfully, but these errors were encountered: