Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 422210

Summary: Wrong content type header provided on diff saves
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ClientAssignee: Eric Moffatt <emoffatt>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Silenio_Quarti
Version: 3.0Keywords: triaged
Target Milestone: 9.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
UNTESTED FIX none

Description Mark Macdonald CLA 2013-11-20 23:29:06 EST
The Orion client sends diff saves as a JSON object 
> { 
>    diff: [{
>       start: 0, end: 1, text: "a"
>    }]
> }

However it does not set a Content Type header. This causes the browser to provide 'text/plain' by default (at least in Chrome).

The client should send 'application/json-patch' or 'application/json'.
Comment 1 Eric Moffatt CLA 2015-05-08 09:47:38 EDT
Passing on to the server component on advice from Mark M.
Comment 2 Mark Macdonald CLA 2015-05-08 10:05:52 EDT
Created attachment 253338 [details]
UNTESTED FIX

I misunderstood the description. Sending back to client.

BTW this should be a trivial change: attaching a (untested) patch.
Comment 3 Eric Moffatt CLA 2015-05-08 10:35:12 EDT
kk, I'll take the easy one :)
Comment 4 Eric Moffatt CLA 2015-06-12 11:11:08 EDT
I've committed Mark's patch, testing that the code is actually used on saves...
Comment 5 Silenio Quarti CLA 2015-06-19 10:28:51 EDT
This changes causes encoding problems when the patch has non-ASCII characters. The change should include the charset as follow:


"application/json;charset=UTF-8"
Comment 6 Mark Macdonald CLA 2015-06-19 12:07:13 EDT
That is a good workaround, but IMO the fact that the server decodes "Content-Type: application/json" in a platform-dependent default character set is a bug. JSON specifies UTF-8 as the default encoding, so that's what should get used.

I opened bug 470615 for this.