Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

rhbz1124630 - need to override accept header for some clients to work #39

Merged
merged 1 commit into from
Dec 15, 2014

Conversation

huangp
Copy link
Collaborator

@huangp huangp commented Dec 11, 2014

Very strange. I needed to add accept header to these two resource clients to make it work.
Otherwise the Accept header will be set to "text/html, image/gif, image/jpeg, *" and on the server it will cause an exception at org/jboss/resteasy/plugins/delegates/MediaTypeHeaderDelegate.java:42 which in result returns a 415 unsupported media type.

I don't need to do this for other clients. I am very confused but this change fixed it.

@huangp
Copy link
Collaborator Author

huangp commented Dec 11, 2014

@seanf can you review this one please? Maybe provide some insight as well?

@@ -50,6 +52,7 @@ private WebResource webResource() {
}

public void put(Project project) {
webResource().put(project);
webResource().accept(MediaType.WILDCARD_TYPE).put(project);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProjectResource only had these values in the @Consumes annotation: MediaTypes.APPLICATION_ZANATA_PROJECT_XML, MediaTypes.APPLICATION_ZANATA_PROJECT_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON

I'm not sure what the implications of Accept */* might be, but I think we should be explicit about our expected media types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the Consume part. It's the client sending a Accept header and the server can't deal with it. I don't know how and why there is this header added (maybe by default?). Noticed the value is "text/html, image/gif, image/jpeg, *" which RESTEasy will try to break it down into two parts by /. It will turn out to be 4 and an exception will be thrown.

In these two clients, we don't really look at what comes back (it's a PUT and no payload in response) that's why I put wildcard for accept.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another strange thing is, other resources and clients don't suffer from this. I just can't see the difference.

@huangp
Copy link
Collaborator Author

huangp commented Dec 12, 2014

@definite can you test this please? It's put-project and put-version using client. I briefly tested other client functionalities they seems to be ok(put-user, glossary etc)

@definite
Copy link
Member

👍

huangp pushed a commit that referenced this pull request Dec 15, 2014
rhbz1124630 - need to override accept header for some clients to work
@huangp huangp merged commit 93fb090 into integration/master Dec 15, 2014
@huangp huangp deleted the rhbz1124630-jersey branch December 15, 2014 05:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants