Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#503 closed defect (wontfix)

Incorrect content type in JsonService

Reported by: anonymous Owned by: alex
Priority: high Milestone:
Component: Core Version: 0.2
Keywords: Cc:
Blocked by: Blocking:

Description

I used JsonService but I got an empty input stream in my servlet. I used TCP monitor to see what's happening, I found that the content type was incorrect.

Here is the capture of TCP monitor:

POST /lnp/resources/pages/Test.page?service=jsonrpc HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q= 0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 46
Pragma: no-cache
Cache-Control: no-cache

{"params":["123","hi"],"method":"test","id":0}

I also found the root cause of this problem. The mimetype is not recognized by dojo.io.XMLHTTPTransport.

I change one line to get it work for me, but it may not be good enough for dojo project. My change is in BrowserIO.js;
The original line is:
http.setRequestHeader("Content-Type", kwArgs.multipart ? ("multipart/form-data; boundary=" + this.multipartBoundary) : (kwArgs.contentType | | "application/x-www-form-urlencoded"));

My new line is:
http.setRequestHeader("Content-Type", kwArgs.multipart ? ("multipart/form-data; boundary=" + this.multipartBoundary) : (kwArgs.contentType | | kwArgs.mimetype | | "application/x-www-form-urlencoded"));

if the core developers can review dojo code and use a consistent name for "contentType" or "mimetype".

Thanks.

Cliff Zhao

Change History (3)

comment:1 Changed 8 years ago by alex

  • Milestone changed from 0.2.2release to 0.3release
  • Owner changed from anonymous to alex
  • Priority changed from highest to high
  • severity changed from blocker to major
  • Status changed from new to assigned

comment:2 Changed 8 years ago by sjmiles

  • Resolution set to wontfix
  • Status changed from assigned to closed

The contentType argument is intended to describe the outgoing request. The mimeType argument is inteded to describe the incoming response.

It can be a confusing distinction, especially because at first it appears odd to have a response type defined at request time. However, trying to detect or guess the proper response type from headers is less robust.

comment:3 Changed 7 years ago by anonymous

  • Milestone 0.3release deleted

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.