Bug 43678 - Handle META tag http-equiv charset?
Handle META tag http-equiv charset?
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: HTTP
2.3.4
Other other
: P2 normal with 1 vote (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-10-23 05:56 UTC by Sebb
Modified: 2010-03-31 02:26 UTC (History)
1 user (show)



Attachments
Path that removes encoding setting in constructor (682 bytes, patch)
2009-09-18 06:55 UTC, Philippe Mouawad
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sebb 2007-10-23 05:56:07 UTC
The HTML tag:
<META http-equiv="Content-Type" content="text/html; charset=utf-8">

is treated by browsers the same as the Content-Type header.

At present (JMeter 2.3) JMeter does not extract this information, it only uses 
headers.

If no charset is present, then the platform default encoding (overridable by 
defining sampleresult.default.encoding) is applied when converting the 
response to a string.

This means that the conversion of the responseData to a string may not produce 
the correct result - for example in the Tree View Listener, and presumably in 
Post-Processors.

JMeter could extract the content-type from the data.
It probably needs to check that the data is intended to be used as HTML first -
 i.e. the existing Content-Type should specify text/html.
Comment 1 Sebb 2007-10-23 17:01:49 UTC
Fixed in SVN r587702
Comment 2 Sebb 2007-10-23 17:15:36 UTC
On further reflection, perhaps this could be improved:

rather than only processing the meta content-type if the header content-type 
did not include a charset/dataEncoding, maybe the meta tag should always be 
processed, and used to update the sampler fields? The original headers would 
still be available from getResponseHeaders.
Comment 3 benoit.wiart 2009-06-08 06:27:10 UTC
the fix in HTTPSampleResult does not work : in the method getDataEncodingWithDefault the test :
   getDataEncodingNoDefault() == null
is always false because of the setDataEncoding(DEFAULT_HTTP_ENCODING); in the constructor

please note that there is no workaround to this bug because DEFAULT_HTTP_ENCODING can not be overriden with sampleresult.default.encoding
Comment 4 benoit.wiart 2009-06-08 08:37:50 UTC
line 42 in  HTTPSampleResult :

setDataEncoding(DEFAULT_HTTP_ENCODING); // default if encoding not provided be the page

should probably be removed
Comment 5 Philippe Mouawad 2009-09-18 06:55:56 UTC
Created attachment 24291 [details]
Path that removes encoding setting in constructor

Hello,
Attached is a patch that applies Benoit Proposition.

If encoding is set through header, encoding declared in meta will not be taken into account.
Otherwise it will.

Philippe
http://www.ubik-ingenierie.com
Comment 6 Sebb 2010-03-31 02:26:40 UTC
Thanks for the patch.

Applied with further fix so ensure correct default was used.

URL: http://svn.apache.org/viewvc?rev=929364&view=rev
Log:
Bug 43678 - Handle META tag http-equiv charset?

Modified:
   jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
   jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
   jakarta/jmeter/trunk/xdocs/changes.xml