Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle META tag http-equiv charset? #2038

Closed
asfimport opened this issue Oct 23, 2007 · 6 comments
Closed

Handle META tag http-equiv charset? #2038

asfimport opened this issue Oct 23, 2007 · 6 comments

Comments

@asfimport
Copy link
Collaborator

Sebb (Bug 43678):
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.

Votes in Bugzilla: 1
Severity: normal
OS: other

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Fixed in SVN r587702

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
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.

@asfimport
Copy link
Collaborator Author

benoit.wiart (migrated from Bugzilla):
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

@asfimport
Copy link
Collaborator Author

benoit.wiart (migrated from Bugzilla):
line 42 in HTTPSampleResult :

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

should probably be removed

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
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

Created attachment patch-HTTPSampleResult.patch: Path that removes encoding setting in constructor

patch-HTTPSampleResult.patch
Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java
===================================================================
--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java	(revision 816394)
+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampleResult.java	(working copy)
@@ -39,7 +39,7 @@
 
     public HTTPSampleResult() {
         super();
-        setDataEncoding(DEFAULT_HTTP_ENCODING); // default if encoding not provided be the page
+//        setDataEncoding(DEFAULT_HTTP_ENCODING); // default if encoding not provided be the page
     }
 
     public HTTPSampleResult(long elapsed) {

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
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:
#2038 - 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant