cURL / Mailing Lists / curl-users / Single Mail

curl-users

curl POST using the -F option

From: David Haggerty <haggerty_at_yfu.org>
Date: Thu, 20 Feb 2003 17:01:17 -0500

I am not having luck posting using the -F (multipart/form-data) option,
which I need to use.

To debug my problem, I created a really simple example that hits a JSP
file that just throws back the values I sent it.

I did three tests.

1) I sent it using curl and option -F
2) I sent it using curl and option -d
3) I created a test form and submitted it that way

When I do (1) and turn verbose on, I don't see it being sent in the header. Shouldn't it display below Content-Type: .... and above the start of the HTML returned the variables I am sending?

Thanks,
David

------------------------ Test 1 ----------------------------------------------------------------

C:\curl>curl -v -F "BatchID=7" http://intranet.yfu.org/jsp/test.jsp
* About to connect() to intranet.yfu.org:80
* Connected to intranet.yfu.org (172.16.1.15) port 80
> POST /jsp/test.jsp HTTP/1.1
User-Agent: curl/7.9.8 (win32) libcurl 7.9.8 (OpenSSL 0.9.6d)
Host: intranet.yfu.org
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Length: 125
Expect: 100-continue
Content-Type: multipart/form-data; boundary=curlEgvitlTuCrcoZga3xi7wUsmAT68

<html>
<body>
Results:

</body>
<html>

------------------------- Test 2 -----------------------------------------

C:\curl>curl -v -d "BatchID=7" http://intranet.yfu.org/jsp/test.jsp
* About to connect() to intranet.yfu.org:80
* Connected to intranet.yfu.org (172.16.1.15) port 80
> POST /jsp/test.jsp HTTP/1.1
User-Agent: curl/7.9.8 (win32) libcurl 7.9.8 (OpenSSL 0.9.6d)
Host: intranet.yfu.org
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Length: 9
Content-Type: application/x-www-form-urlencoded

BatchID=7

<html>
<body>
Results:
BatchID
 -
7
<br>

</body>
<html>

------------------------- Test 3 HTML File -----------------------------------------
<html>
<form method=post action="http://intranet.yfu.org/jsp/test.jsp">
<input size=20 type=text name="BatchID">
</form>
</html>

------------------------- Test 3 Results -----------------------------------------

<html>
<body>
Results:
BatchID
 -
7
<br>

</body>
<html>

-------------------JSP Program if anyone wants to look at it --------------------------
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<html>
<body>
Results:
<%
Enumeration enum = request.getParameterNames();

while (enum.hasMoreElements()){
    String param = (String)enum.nextElement();
    out.println(param);
    String val = request.getParameter(param);
    out.println(" - ");
    out.println(val);
    out.println("<br>");
}
%>
</body>
<html>

-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
Received on 2003-02-20