atmosphere icon indicating copy to clipboard operation
atmosphere copied to clipboard

Content-Type in query string not added as header before passing request to Jersey

Open nite23 opened this issue 14 years ago • 9 comments

The client is set up with:

request.transport = 'long-polling';
request.contentType = 'application/json'; 
request.enableXDR = true;
request.dropAtmosphereHeaders = true;   
request.attachHeadersAsQueryString = true; 

When a push() is issued on IE 8/9, Content-Type is omitted from headers and appended to URI. But on the server-side, it is apparently not added back into headers before the request is sent to Jersey for processing.

As a result, Jersey will fail unmarshalling a JSON message to POJO:

SEVERE|glassfish3.1.2|com.sun.jersey.spi.container.ContainerRequest|_ThreadID=530;_ThreadName=Thread-2;|A message body reader for Java class org.example.Message, and Java type class org.example.Message, and MIME media type application/octet-stream was not found.

On browsers that support CORS, Content-Type is not dropped, but it's changed to "text/plain; charset=UTF-8".

In that case, request fails with "415 Unsupported Media Type".

nite23 avatar Jul 05 '12 11:07 nite23

Hum...it should :-) I've just tested and I do see the content-type. Can you use latest SNAPSHOT and let me know? Please -reopen if I missed something.

jfarcand avatar Jul 09 '12 15:07 jfarcand

Issue remains with the latest snapshot. I tested it on the rest-chat sample as well.

I forgot to mention I use Jersey 1.9.1, which is a lot newer than what ships with Glassfish (1.1, I think) ... could this be a problem?

nite23 avatar Jul 09 '12 19:07 nite23

Can you tell me what the client is sending? Use wireshark or ngrep to see what goes on the wire. I want to see how the URL looks like and the headers passed by CORS browser. Thanks

jfarcand avatar Jul 10 '12 06:07 jfarcand

this is from firefox:

suspend:

GET /atmosphere-rest-chat/chat?X-Atmosphere-tracking-id=949dc60a-9b90-8a47-91b5-b759de885aff&X-Atmosphere-Framework=1.0&X-Atmosphere-Transport=long-polling&X-Cache-Date=0&Content-Type=application/json&=1341905545594 HTTP/1.1 Host: xxxxx:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8 Accept-Language: en-us,en;q=0.7,cs;q=0.3 Accept-Encoding: gzip, deflate Connection: keep-alive Referer: http://www.xxxxx/test.php Origin: http://www.xxxxx

broadcast:

POST /atmosphere-rest-chat/chat?X-Atmosphere-tracking-id=949dc60a-9b90-8a47-91b5-b759de885aff&X-Atmosphere-Framework=1.0&X-Atmosphere-Transport=polling&X-Cache-Date=0&Content-Type=application/json&=1341905558980 HTTP/1.1 Host: xxxxx:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8 Accept-Language: en-us,en;q=0.7,cs;q=0.3 Accept-Encoding: gzip, deflate Connection: keep-alive Referer: http://www.xxxxx/test.php Content-Length: 120 Content-Type: text/plain; charset=UTF-8 Origin: http://www.xxxxx Pragma: no-cache Cache-Control: no-cache

response:

HTTP/1.1 415 Unsupported Media Type X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2 Java/Oracle Corporation/1.7) Server: GlassFish Server Open Source Edition 3.1.2 X-Atmosphere-tracking-id: 14aae8df-de41-4244-874a-57eb430abfaf Content-Type: text/html Content-Length: 1232

nite23 avatar Jul 10 '12 07:07 nite23

Really strange. It may be a clash of Jersey version as the content-type is properly passed. Send me a private email at [email protected] and I will send you a patch that show which headers are passed to Jersey. That way we will know for sure where is the issue. Thanks!

jfarcand avatar Jul 10 '12 07:07 jfarcand

Fixed

https://github.com/Atmosphere/atmosphere/commit/275396ffbd1f1f831ba9f0470f026e2394d0b02b#commitcomment-1559872

jfarcand avatar Jul 10 '12 09:07 jfarcand

Thanks. You planned a hotfix version for 1.0.0 ?

b0c1 avatar Jul 10 '12 14:07 b0c1

Releasing 1.0.0.beta3 as of now :-) wait 1 hour and the artifact will be available :-)

jfarcand avatar Jul 10 '12 14:07 jfarcand

Thnx a lot.

b0c1 avatar Jul 10 '12 14:07 b0c1