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

Bug 318373

Summary: org.eclipse.ecf.remoteservice.rest.client.RestClientService encodes the parameter name/value pairs twice
Product: [RT] ECF Reporter: Nicolas Rouquette <nicolas.f.rouquette>
Component: ecf.remoteservicesAssignee: Scott Lewis <slewis>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: slewis
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch for RestClientService::toNameValuePairs() to remove the redundant encoding of the name/value pairs. none

Description Nicolas Rouquette CLA 2010-06-29 15:19:23 EDT
There is a subtle bug in the ECF framework that results in a double encoding of HTTP post/get/put requests.

The methods RestClientService::prepare[X]Method for X = Post, Get, Put follow the same pattern to set the request query string from the request parameters:

		HttpMethod result =...

		NameValuePair[] params = toNameValuePairs(uri, call, callable);
		if (params != null)
			result.setQueryString(params);
		return result;
		
According to doc, org.apache.commons.httpclient.HttpMethod.setQueryString(NameValuePair[]) already encodes the name value pairs.
This is on top of the encoding that RestClientService::toNameValuePairs() currently does, resulting in doubly encoded name/value pairs in the query string.

The suggested fix is to simply remove the encoding in RestClientService::toNameValuePairs() as shown in the attached patch.
Comment 1 Nicolas Rouquette CLA 2010-06-29 15:20:22 EDT
Created attachment 173037 [details]
Patch for RestClientService::toNameValuePairs() to remove the redundant encoding of the name/value pairs.
Comment 2 Scott Lewis CLA 2010-06-29 16:06:41 EDT
Thanks for the report and the patch Nicolas.  I'll review the patch and apply/release to HEAD as soon as I can.
Comment 3 Scott Lewis CLA 2010-06-30 10:55:47 EDT
Patch applied and released to HEAD.  Thanks again Nicolas for the report and the fix.
Comment 4 Scott Lewis CLA 2010-06-30 12:41:40 EDT
Also applied patch to Release_3_3 stream (for 3.3.1 service release).