curl-library
Re: How to "PUT" http body to HTTP PUT in libcurl
Date: Wed, 27 Jan 2016 11:58:06 -0500
According to your instruction - "Changing the
CURLOPT_POST to a CURLOPT_PUT ought to get you what you want". The result
of "405 Method Not Allowed" makes me feel uncomfortable. Please advise
The following are the output for before changing CURLOPT_POST to CURLOPT_PUT,
and after the change
========BEFORE THE CHANGE (i.e. using CURLOPT_POST)==============
* About to connect() to example.com port 80 (#0)
* Trying 2606:2800:220:1:248:1893:25c8:1946...
* Protocol error
* Trying 93.184.216.34...
* Connected to example.com (93.184.216.34) port 80 (#0)
> POST /index.cgi HTTP/1.1
Host: example.com
Accept: */*
Content-Length: 44
Content-Type: application/x-www-form-urlencoded
< HTTP/1.1 404 Not Found
< Cache-Control: max-age=604800
< Date: Wed, 27 Jan 2016 16:49:39 GMT
< Expires: Wed, 03 Feb 2016 16:49:39 GMT
< Server: EOS (lax004/45C0)
< Content-Length: 454
< Content-Type: text/html
< Via: 1.1 inprthop11p.corp.emc.com:80 (Cisco-WSA/8.5.3-051)
< Connection: keep-alive
* HTTP error before end of send, stop sending
<
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
<script type="text/javascript" src="
http://gp1.wpc.edgecastcdn.net/00222B/jtest/tpbeacontest.js"></script>
</body>
</html>
* Closing connection 0
========AFTER THE CHANGE (i.e. CURLOPT_PUT )==============
* About to connect() to example.com port 80 (#0)
* Trying 2606:2800:220:1:248:1893:25c8:1946...
* Protocol error
* Trying 93.184.216.34...
* Connected to example.com (93.184.216.34) port 80 (#0)
> PUT /index.cgi HTTP/1.1
Host: example.com
Accept: */*
Transfer-Encoding: chunked
Expect: 100-continue
< HTTP/1.1 100 Continue
< HTTP/1.1 405 Method Not Allowed
< Cache-Control: max-age=604800
< Date: Wed, 27 Jan 2016 16:50:35 GMT
< Expires: Wed, 03 Feb 2016 16:50:35 GMT
< Server: EOS (lax004/2812)
< Content-Length: 0
< Via: 1.1 inprthop11p.corp.emc.com:80 (Cisco-WSA/8.5.3-051)
< Connection: keep-alive
<
* Connection #0 to host example.com left intact
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2016-01-27