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

Add content-type header = application/json for create and update actions #152

Merged
merged 1 commit into from
Feb 25, 2016

Conversation

abonas
Copy link
Member

@abonas abonas commented Feb 23, 2016

Following PR Split codec from scheme #17922 on k8s server.
kubernetes/kubernetes#17922

Without sending content-type, the requests fail.
cc @simon3z

Following PR  Split codec from scheme #17922 on k8s server.
@simon3z
Copy link
Collaborator

simon3z commented Feb 23, 2016

@abonas I think that post and put support :content_type in the request. E.g.

rest_client[ns_prefix + resource_name(entity_type)].post(hash.to_json, @headers, :content_type => 'application/json')

It looks just slightly better (because closer to the to_json transformation), but I don't know if it works.
(Not sure if it's worth investigating, up to you)

Should we do something for what format we expect in the response? E.g. passing the Accept: application/json header to be sure to receive json?

@abonas
Copy link
Member Author

abonas commented Feb 24, 2016

@abonas I think that post and put support :content_type in the request. E.g.

rest_client[ns_prefix + resource_name(entity_type)].post(hash.to_json, @headers, :content_type => 'application/json')
It looks just slightly better (because closer to the to_json transformation), but I don't know if it works.
(Not sure if it's worth investigating, up to you)

@simon3z
I thought about it too, saw some examples that use it. What bothered me is that eventually content type is a header, and there is already a headers object passed. Differentiating it can confuse the reader since it will create 2 different ways of passing headers.
Thoughts?

Should we do something for what format we expect in the response? E.g. passing the Accept: application/json header to be sure to receive json?

It does work without passing Accept, and I remember there were some exceptions that were sent in response as text instead of json from k8s server ( a bug, but still...) , so passing Accept can actually prevent the client from getting an exception from the server.
So I tend to say not to send Accept at the moment.

@simon3z
Copy link
Collaborator

simon3z commented Feb 24, 2016

OK 👍

abonas added a commit that referenced this pull request Feb 25, 2016
Add content-type header = application/json for create and update actions
@abonas abonas merged commit 5c75634 into master Feb 25, 2016
@simon3z simon3z deleted the addContentTypeJsonCreateUpdate branch April 28, 2017 12:19
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.

None yet

2 participants