Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 7.0.0.pre5, 6.1.14
-
Fix Version/s: 6.1.15.pre0
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
from the mailing list:
Hensley, Richard wrote:
> I ran into an interesting situation using the HttpTester class. The
> basic problem is that the response from my servlet is encoded in UTF-8,
> and the HttpTester.parse(String rawHTTP) uses ISO-8859 and platform
> encoding for the string character encoding, which may not contain all
> the needed code points. Also, HttpTester.getContent() uses platform
> encoding to interpret the raw bytes of the parsed content, which may not
> be right at all.
>
> In order to accommodate my needs, I had to add the following two methods
> to a derived class. They might be useful in the HttpTester class.
>
> /**
>
> * Ensure that the parsed content is decoded using the correct
> character set. The HTTP parser just dumps raw
>
> * bytes into the _parsedContent. This method simply interprets
> the bytes using the specified character
>
> * encoding.
>
> *
>
> **** @param* charsetName
>
> **** @return*
>
> **** @throws* UnsupportedEncodingException
>
> */
>
> *** public* String getContent(**final String charsetName)
>
> *** throws* UnsupportedEncodingException
>
> {
>
> *** if* (_parsedContent !=*** null*)
>
>
>
> *** return**** super*.getContent();
>
> }
>
> /**
>
> * This method is used to ensure that the response is parsed as
> bytes. This is in contrast to the parse(String
>
> * rawHttp) method which converts the passed in string into
> bytes using ISO08859 encoding.
>
> *
>
> **** @param* bytes
>
> **** @return*
>
> **** @throws* IOException
>
> */
>
> *** public* String parseBytes(**final*** byte*[] bytes)
>
> *** throws* IOException
>
>
>
David,
I think the patch is mostly right, however:
+ can you make the default encoding utf-8 if the () constructor is used.
+ can you make the _charset only the default to be used when there is not a charset
specified in either request and/or response content type headers
cheers