Discussion:
jp@gc - HTTP Raw Request for POST requests
sasidharsmit
2011-07-26 14:46:09 UTC
Permalink
Dear All,
I'm trying out the "***@gc - HTTP Raw Request" sampler to send in HTTP POST
requests to the server.

My request in the "Request Data" section of the sampler, looks like the one
below:
*/
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: jmeter
Cache-Control: no-store,no-cache
Pragma: no-cache
Accept-Encoding: gzip, deflate
Accept: */*
Host: abc.com

command.....<rest of the body>
/*

The problem I'm facing is that, when I send this request, I always get the
below error:

*/&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 2.0//EN&quot;&gt;
<html><head>
<title>400 Bad Request</title>
</head><body>
Bad Request

<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.3 (Red Hat) Server at abc.com Port 80</address>
</body></html>/*

I referred to the documentation for this sampler at the below location:

http://code.google.com/p/jmeter-plugins/

Nothing much has been mentioned in reference to the POST requests. So, I'm
not sure if the details, I'm mentioning in the "Request Data" section of
this sampler, is in the right format or not.

Has anyone else tried this particular sampler? Can you help me?

Cheers,
Sasi

--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4635060.html
Sent from the JMeter - User mailing list archive at Nabble.com.
apc
2011-07-26 15:03:41 UTC
Permalink
Hi,

Your request missing Content-Length header, required for correct POST
request.

Everything else is ok.

-----
--
Andrey Pohilko
***@GC Maintainer
--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4635139.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sasidharsmit
2011-07-26 16:14:53 UTC
Permalink
Thanks Andrey.

Despite giving the content length, I still get the same 400 error.

My request in the "view results in a tree" listener looks like the one
below:

*/POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: jmeter
Cache-Control: no-store,no-cache
Pragma: no-cache
Accept-Encoding: gzip, deflate
Accept: */*
Host: abc.com
Content-Length: 645
command=...<rest of the body>
Request Headers:/*

If I look at the above request, I find "Request Headers:" at the bottom and
it looks empty. Is it that I have put the request header in the wrong place?

Cheers,
Sasi

--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4635405.html
Sent from the JMeter - User mailing list archive at Nabble.com.
apc
2011-07-26 16:46:03 UTC
Permalink
Note you missed double newline between headers and body...

-----
--
Andrey Pohilko
***@GC Maintainer
--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4635515.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sasidharsmit
2011-07-27 12:36:33 UTC
Permalink
Thanks Andrey.

I tried adding double newline between the header and the body. It resolved
my issue of "400 Bad Request".

But then, I did not get the response I expected. My request did reach the
right server and the server did respond with a proper HTTP 200 response
code. But, the response I receive is not what I expect.

I did some investigation on this by testing my requests with the
firefox-addon "HTTPRequester". I found the cause of the problem:

1. When I send my request with the Content-Type,
"application/x-www-form-urlencoded", I get the correct response from the
server.
2. When I send my request with any other Content-Type, say "text/plain", I
get the unexpected response (with HTTP 200 code) from the server, which is
the same as that I get in JMeter.

So, I understand that the header "Content-Type", is the one that is causing
the issue.

So, I hooked up wireshark to my machine and tried to sniff the network
packets, to see if the content type that I'm setting in JMeter
("application/x-www-form-urlencoded"), is same as the one which is sent from
my machine to the server.

Surprisingly, it is the same. I could see "Content-Type:
application/x-www-form-urlencoded" in the packets sniffed.

So, I'm sending a request with the "Content-Type:
application/x-www-form-urlencoded", but the server is treating my request
as, one with "Content-Type: text/html".

This happens only when I do it with JMeter. When I try the same with
"HTTPRequestor" add-on, I get the proper response.

I do not know, where the problem is. Can you help?

Cheers,
Sasi

--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4638624.html
Sent from the JMeter - User mailing list archive at Nabble.com.
apc
2011-07-27 15:28:10 UTC
Permalink
There's some difference in request that you send via JMeter and another tool.
Use Wireshark to find that difference.

-----
--
Andrey Pohilko
***@GC Maintainer
--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4639181.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sasidharsmit
2011-07-29 08:23:55 UTC
Permalink
Apparently, there are two response for requests to the same URI "abc.com":

1. When the request is a "get" request, I get the response as text/html
2. When the request is a "post" request, I get the response as text/plain
(which is what I want)

When I send the "POST" request via other tools, I get the proper response.
But, when I send the "POST" response via JMeter, I get the "text/html"
response which indicates that my "POST" request is actually being treated as
a get request.

I wonder if my request syntax has anything to do with it.

I have attached a snapshot of my "raw http request" page. Can you have a
look at it and see if there is anything that makes JMeter consider this as a
"get" request?

Loading Image...

Cheers,
Sasi

--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4646216.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sasidharsmit
2011-07-29 09:05:15 UTC
Permalink
At last, got a solution for this.

Andrey,
As you had mentioned in your earlier POST, I was comparing the Wireshark
monitors for JMeter and HTTPRequestor.

Everything was same, except that my JMeter request had a "Malformed Packet:
GIF Image" in the HTTP section.

So, I compared the HTTP section and found that there is a single difference
between these two requests:

The difference was "\r\n" (i.e.) one extra line space. So, instead of having
a double line space between the header and the body, in JMeter, I used a
single line space and .... voila!!....it worked! :-D

So, everything works fine now.

*Solution:* Use a single empty line space between the Headers and the body.

Thanks for your support, Andrey.

Cheers,
Sasi

--
View this message in context: http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4646304.html
Sent from the JMeter - User mailing list archive at Nabble.com.
Adrian Speteanu
2011-07-29 09:29:20 UTC
Permalink
That's the thing with HTTP Multi-part Post - some little details count
extremely much while others are disregarded, so unless you want to learn the
standard by heart, you have to be painfully careful to replicate the browser
request properly. And unfortunately there are no general solutions, you just
have to take it step by step. I had a combination of multi-part posts and
rfc "conflicting" with the way i designed the requests, and took me ages to
get it working in all situations i needed them too.
Post by sasidharsmit
At last, got a solution for this.
Andrey,
As you had mentioned in your earlier POST, I was comparing the Wireshark
monitors for JMeter and HTTPRequestor.
GIF Image" in the HTTP section.
So, I compared the HTTP section and found that there is a single difference
The difference was "\r\n" (i.e.) one extra line space. So, instead of having
a double line space between the header and the body, in JMeter, I used a
single line space and .... voila!!....it worked! :-D
So, everything works fine now.
*Solution:* Use a single empty line space between the Headers and the body.
Thanks for your support, Andrey.
Cheers,
Sasi
--
http://jmeter.512774.n5.nabble.com/jp-gc-HTTP-Raw-Request-for-POST-requests-tp4635060p4646304.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
Loading...