Bug 37716 - Invalid request using Proxy for a multipart/form-data with no filename specified.
Summary: Invalid request using Proxy for a multipart/form-data with no filename specif...
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.1.2
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-30 14:25 UTC by Benjamin Francisoud
Modified: 2005-12-02 01:33 UTC (History)
0 users



Attachments
Cocoon stacktrace (6.46 KB, text/html)
2005-11-30 14:26 UTC, Benjamin Francisoud
Details
simple multipart form (564 bytes, text/html)
2005-11-30 14:30 UTC, Benjamin Francisoud
Details
webrick - ruby on rails - stacktrace (2.16 KB, text/plain)
2005-11-30 14:31 UTC, Benjamin Francisoud
Details
replace sampler.getFileField() with sampler.getFilename() (1.05 KB, patch)
2005-11-30 14:38 UTC, Benjamin Francisoud
Details | Diff
junit test case for PostWriter (6.88 KB, application/octet-stream)
2005-11-30 17:37 UTC, Benjamin Francisoud
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Francisoud 2005-11-30 14:25:19 UTC
When using the JMmeter proxy (to record pages) on a multipart/form-data whith an
upload file field, if the filename is not specified, an invalid request is send
to the server.

My actual webapp (with cocoon) and the form are too complex to be put as an
attachment, but I'll provide the stacktrace.

I recreated the same problem using a simple form with ruby on rails, I'll put
the webrick stacktrace too.

I think I've spoted the problem in PostWriter.java, I'll provide a patch (as
soon as I'll have checkout sources from svn).
Comment 1 Benjamin Francisoud 2005-11-30 14:26:35 UTC
Created attachment 17084 [details]
Cocoon stacktrace
Comment 2 Benjamin Francisoud 2005-11-30 14:30:42 UTC
Created attachment 17086 [details]
simple multipart form

The simple html page I used in ruby on rails to reproduce the problem with the
jmeter proxy.
Comment 3 Benjamin Francisoud 2005-11-30 14:31:45 UTC
Created attachment 17087 [details]
webrick - ruby on rails - stacktrace

The stacktrace I get when using jmeter proxy with the simple form with no
filename specified.
Comment 4 Benjamin Francisoud 2005-11-30 14:37:50 UTC
I spotted the problem in org.apache.jmeter.protocol.http.sampler.PostWriter.java

In sendPostData(), the filename is tested with those lines:
String filename = sampler.getFilename();
if ((filename != null) && (filename.trim().length() > 0)) {

But in setHeaders(), the filename is not use:
String filename = sampler.getFileField();
if ((filename != null) && (filename.trim().length() > 0)) {

Where sampler.getFileField() is the "name" attribut of the html input ("upload"
in my simple multipart form attachment file), therefore wrong headers a used.

See patch-bug-37716.txt
Comment 5 Benjamin Francisoud 2005-11-30 14:38:46 UTC
Created attachment 17088 [details]
replace sampler.getFileField() with sampler.getFilename()
Comment 6 Benjamin Francisoud 2005-11-30 17:37:47 UTC
Created attachment 17089 [details]
junit test case for PostWriter

Test all public methodes of PostWriter.
Place it under:
[jmeter-workspace]/test/src/org/apache/jmeter/protocol/http/sampler

Done under windows XP and eclipse 3.1.

Launch from eclipse: green bar.
Launch from ant: green bar.
Comment 7 Sebb 2005-12-01 00:10:45 UTC
Thanks very much - it's particularly useful to have the JUnit testcase.

I've applied the patch to the 2.1 branch.

BTW, PostWriter.CRLF and PostWriterTest.CRLF need to remain private - final
arrays are mutable (unless they have zero entries), so it's not completely safe
to share them.
Comment 8 Benjamin Francisoud 2005-12-02 10:33:47 UTC
solve with the latest svn sources :)
Comment 9 The ASF infrastructure team 2022-09-24 20:37:36 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1642