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

Bug 313029

Summary: HttpClient gets http content in ISO-8859-1 instead UTF-8
Product: [RT] ECF Reporter: Pavel Samolisov <samolisov>
Component: ecf.remoteservicesAssignee: ecf.core-inbox <ecf.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: samolisov, slewis
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch, that fixed this bug slewis: iplog+

Description Pavel Samolisov CLA 2010-05-16 03:27:59 EDT
Build Identifier: 

HttpClient gets http content in its default encoding - ISO-8859-1. If page content contains do not ASCII symbols, they transform to unreadable symbols sequences, for example: Ð&#159;о пÑ&#128;оÑ&#129;Ñ&#140;бам Ñ&#135;иÑ&#130;аÑ&#130;елей.

I made small patch - add in method createAndPrepareHttpMethod(...) of class RestClientService folows string: 

httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, DEFAULT_HTTP_CONTENT_CHARSET);

DEFAULT_HTTP_CONTENT_CHARSET is java constant:

protected final static String DEFAULT_HTTP_CONTENT_CHARSET = "UTF-8"; //$NON-NLS-1$

Reproducible: Always
Comment 1 Pavel Samolisov CLA 2010-05-16 03:30:27 EDT
Created attachment 168644 [details]
patch, that fixed this bug
Comment 2 Scott Lewis CLA 2010-05-16 12:00:26 EDT
Hi Pavel,

I can apply this patch, but would like to ask one question

To your knowledge, is there any possibility of regression (breaking something else) by applying this patch.  If so, what?
Comment 3 Pavel Samolisov CLA 2010-05-16 12:07:36 EDT
Thanks, Scott

I think this patch does not breake anything. If ECF REST client is trying to get data from URL with content by ASCII symbols only - it will get correcting content. This one just set correct behavior for not ASCII content.
Comment 4 Scott Lewis CLA 2010-05-16 12:18:35 EDT
Ok Pavel.  Thanks.  One thing to point out about this...it is possible for RestClientService subclasses to override createAndPrepareHttpMethod and set the options for the HttpMethod as desired.

I've applied patch, tested, and released to HEAD.  Thanks for the report and patch, Pavel.  Resolving as fixed.
Comment 5 Pavel Samolisov CLA 2010-05-16 12:45:50 EDT
Thanks, Scott! I think this is really will help for not english-language users.