You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by bu...@apache.org on 2007/03/24 19:56:33 UTC

DO NOT REPLY [Bug 27780] - create multipart/form-data HTTP request without uploading file

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27780>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27780





------- Additional Comments From alf@i100.no  2007-03-24 11:56 -------
Created an attachment (id=19792)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19792&action=view)
Suggested patch

This is a sugggested patch for improving the HTTP POST request functionality.

This patch adds support for using multipart/form-data even if no file is being
uploaded. I have not currently added a property in the jmeter.properties file
to control that you want multipart/form-data. In the start, I want to let the
Proxy Server create "HTTP Samplers" that are using multipart/form-data.

More headers are set both on the request, and in the multiparts, for both
HTTPSampler and HTTPSampler2. That means that both content-type, and
content-length are now set.

Also the encoding used are set for the multiparts.
I think this means that different encodings are now supported for POSTs. You
have to set the "content encoding" in the "HTTP Request" gui, to have the POST
sent with the correct encoding. This applies for both x-www-form-urlencoded and
multipart/form-data. The "HTTPSamplerBase.getQyeryString" could not be used,
since that always encodes to UTF-8, also the parameter values.

Both the HTTPSampler and HTTPSampler2 is changed, so that the "querystring"
which is set on the created sample, more fully represents what is being sent to
the web server. For multipart/form-data, that means that the multiparts are
displayed, except the actual file content.

It changes PostWriter, by changing methods to non-static, i.e. requiring that
PostWriter is instantiated. This is needed to keep state set in "setHeaders",
and reuse that state when doing "sendPostHeaders".

What I currently do not like about the patch :
HTTPSampler and HTTPSampler2 are using different "default encoding" if none is
specified in the "HTTP Request" GUI. HTTPSampler uses iso-8859-1, while
HTTPSampler2 uses us-ascii. I think both should use the same default encoding.
I think the default should be iso-8859-1, I think that is what most browsers
use by default.

The HTTPSampler currently provides the full path to the file in the header of
the file multipart. I think it is correct to only include the filename. That is
also what the HTTPSampler2 does.

I am not 100% confident that I am handling the "httpargument.isalwaysencoded"
correctly. As of now, I ignore it, and always encode the parameter name and
value. I think the "isalwaysencoded" only applies to parameters that should be
used in a HTTP GET request. But I might very well be wrong.

Conclusion :
I think this patch has potential for solving a number of issues related to HTTP
POST handling. But please have a review of the code, and ask and comment about
the code. I'll also look into making some automated tests for HTTP POST
handling.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org