Bug 42098 - Use specified encoding for parameter values in HTTP GET
Use specified encoding for parameter values in HTTP GET
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: HTTP
2.2
All All
: P2 enhancement (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-04-12 04:38 UTC by Alf Hogemark
Modified: 2007-04-14 05:51 UTC (History)
0 users



Attachments
Suggested patch for encoding HTTP GET urls (29.76 KB, patch)
2007-04-12 04:43 UTC, Alf Hogemark
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alf Hogemark 2007-04-12 04:38:05 UTC
Currently, the HTTP Samplers always url encode the parameter values using the
UTF-8 encoding when a HTTP GET request is made. This is according to the HTTP
specification.

But most, if not all browsers, do not follow the specification when urlencoding
for HTTP GET request. Most browsers use the encoding of the page where the form
was present, or uses the value of the "accept-charset" attribute for the <form>
html tag.

Since the HTTP Request GUI currently has a field "Content encoding", which is
used in HTTP POST request to encode the URL for HTTP Post according to the
specified encoding, I would like to suggest the same functionality for HTTP GET.

This means that if the user has filled in a value in "Content encoding", and is
doing a HTTP GET, then the specified encoding will be used to encode the
parameter values, if encoding checkbox is on. Only the parameter value will be
encoded with this encoding, the parameter name will always be encoded using UTF-8.
If the user has not specified a value for "Content encoding", then "UTF-8" will
be used, which is like it is today.

I think this patch makes it possible to let Jmeter behave more like other browsers.
Comment 1 Alf Hogemark 2007-04-12 04:43:54 UTC
Created attachment 19935 [details]
Suggested patch for encoding HTTP GET urls

The suggested patch lets the HTTPSamplerBase construct the query string by
encoding parameter values according to the specified encoding.
This also means that the PostWriter can use this
getQueryString(contentEncoding) method, instead of having it's own version of
the method.

I have also added unit tests to TestHTTPSamplersAgainstHttpMirrorServer. If you
only apply the unit test, then the test from line 353 will fail.
I.e. where the values are set like this :
titleValue = "mytitle\uc385";
descriptionValue = "mydescription\uc385";
Because these values look different when url encoded in utf-8 and iso-8859-1.

This patch will also make it easier to add functionality to the HTTP Proxy
server.
Comment 2 Sebb 2007-04-14 05:51:15 UTC
Thanks, applied to SVN in r528800