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

Bug 334701

Summary: [server] Preference PUT format does not scale
Product: [ECD] Orion Reporter: John Arthorne <john.arthorne>
Component: ClientAssignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: simon_kaegi
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description John Arthorne CLA 2011-01-18 15:46:43 EST
Our current REST API for preferences does this to change a single value:

PUT /prefs/user/myprefs?key=Name&value=Gilgamesh

However this puts a severe limit on the size of the preference value, since it must be encoded directly in the request URL. We should support a different format that puts the preference value in the request body:

----
PUT /prefs/user/myprefs?key=Name

Very larger value goes here...
-----
Comment 1 John Arthorne CLA 2011-01-18 15:48:53 EST
For PreferencesServlet:

private String getBodyAsString(HttpServletRequest req) throws IOException {
		StringWriter writer = new StringWriter();
		IOUtilities.pipe(req.getReader(), writer, true, false);
		return writer.toString();
	}
Comment 2 John Arthorne CLA 2011-02-03 16:32:47 EST
Fixed. Putting a single value now uses a form-encoded request body, which is more standard for PUT operations.
PUT /prefs/user/myprefs
Orion-Version: 1.0
Content-Length: 21
Content-Type: "application/x-www-form-urlencoded"

key=Name&value=Enkidu
Comment 3 Simon Kaegi CLA 2011-02-03 17:49:25 EST
Hmm... is that a complete representation of /prefs/user/myprefs or just a PATCH?
Comment 4 John Arthorne CLA 2011-02-04 09:43:08 EST
(In reply to comment #3)
> Hmm... is that a complete representation of /prefs/user/myprefs or just a
> PATCH?

It is just a single key/value. This can also be expressed as the following if you prefer this equivalent syntax:

PUT /prefs/user/myprefs?key=Name

value=Frodo