POST request parameters not being included
"Ryan Graciano" <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm trying to send a POST request with an arbitrary XML payload and a number
of arbitrary request parameters, but none of my request parameters are being
sent by HttpUnit. They appear to be ignored entirely. I wrote up a test
class to demonstrate the problem, and then I ran netcat on port 7777 to
print out the response. As you can see in the below example, the parameters
are missing, and it should also be noted that the httpunit client version is
not correct (1.5, when I am using 1.6.2). I would appreciate it if someone
would point out the problem if I'm using the API incorrectly; otherwise,
I'll submit a pair of defects.
First I will paste the code, and then what I saw in netcat -
***** CODE *****
package scratch;
import java.io.ByteArrayInputStream;
import com.meterware.httpunit.PostMethodWebRequest;
import com.meterware.httpunit.WebConversation;
public class PostTest {
public static byte[] getXML() {
return "<test><1>blah</1><2>blah</2></test>".getBytes();
}
public static void main(String[] args) throws Exception {
WebConversation wc = new WebConversation();
wc.setAuthorization("user", "pass");
ByteArrayInputStream inputStream = new
ByteArrayInputStream(getXML());
String url = "http://localhost:7777/first/second";
PostMethodWebRequest postRequest = new PostMethodWebRequest(url,
inputStream, "text/xml");
postRequest.setParameter("foo", "bar");
postRequest.setParameter("a", "b");
postRequest.setMimeEncoded(false);
wc.getResponse(postRequest);
}
}
***** NETCAT *****
POST /first/second HTTP/1.1
User-Agent: httpunit/1.5
Accept-Encoding: gzip
Authorization: Basic dXNlcjpwYXNz
Content-Type: text/xml
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:7777
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 35
<test><1>blah</1><2>blah</2></test>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop