curl-library
RE: Can someone explain why curl_easy_reset is not working?
Date: Sat, 24 May 2014 20:30:06 +0000
> Now that is an excellent test and I think the reason for this behavior is
> simply that it doesn't actually reset the URL! This is in fact a bug as far as
> I can tell, even if I don't think it is a very critical one. It does reset all
> (most?) other options.
>
> --
>
> / daniel.haxx.se
Well, I was trying to do that. And now, it's even more, strange...
Requesting the following: http://posttestserver.com/post.php
B$ node test.js http://posttestserver.com/post.php
* Hostname was NOT found in DNS cache
* Trying 67.205.14.22...
* Connected to posttestserver.com (67.205.14.22) port 80 (#0)
> GET /post.php HTTP/1.1
Host: posttestserver.com
Accept: */*
< HTTP/1.1 200 OK
< Date: Sat, 24 May 2014 20:18:07 GMT
* Server Apache is not blacklisted
< Server: Apache
< Access-Control-Allow-Origin: *
< Vary: Accept-Encoding
< Content-Length: 140
< Content-Type: text/html
<
* Connection #0 to host posttestserver.com left intact
Err: [Error: URL using bad/illegal format or missing URL]
Ok, the reset worked. Let's try to send some data using curl.setOpt( Curl.option.POSTFIELDS, 'field=name' );
B$ node test.jshttp://posttestserver.com/post.php
* Hostname was NOT found in DNS cache
* Trying 67.205.14.22...
* Connected to posttestserver.com (67.205.14.22) port 80 (#0)
> POST /post.php HTTP/1.1
Host: posttestserver.com
Accept: */*
Content-Length: 10
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 10 out of 10 bytes
< HTTP/1.1 200 OK
< Date: Sat, 24 May 2014 20:20:10 GMT
* Server Apache is not blacklisted
< Server: Apache
< Access-Control-Allow-Origin: *
< Vary: Accept-Encoding
< Content-Length: 140
< Content-Type: text/html
<
* Connection #0 to host posttestserver.com left intact
Err: [Error: URL using bad/illegal format or missing URL]
Worked again, let's set HTTPPOST after resetting (using same data):
this.reset();
curl.setOpt( Curl.option.POSTFIELDS, 'field=name' );
B$ node test.js http://posttestserver.com/post.php
* Hostname was NOT found in DNS cache
* Trying 67.205.14.22...
* Connected to posttestserver.com (67.205.14.22) port 80 (#0)
> POST /post.php HTTP/1.1
Host: posttestserver.com
Accept: */*
Content-Length: 10
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 10 out of 10 bytes
< HTTP/1.1 200 OK
< Date: Sat, 24 May 2014 20:22:53 GMT
* Server Apache is not blacklisted
< Server: Apache
< Access-Control-Allow-Origin: *
< Vary: Accept-Encoding
< Content-Length: 141
< Content-Type: text/html
<
* Connection #0 to host posttestserver.com left intact
Err: [Error: URL using bad/illegal format or missing URL]
Nice. Let's change the data used after the reset:
this.reset();
curl.setOpt( Curl.option.POSTFIELDS, 'field-changed=name' );
B$ node test.js http://posttestserver.com/post.php
* Hostname was NOT found in DNS cache
* Trying 67.205.14.22...
* Connected to posttestserver.com (67.205.14.22) port 80 (#0)
> POST /post.php HTTP/1.1
Host: posttestserver.com
Accept: */*
Content-Length: 10
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 10 out of 10 bytes
< HTTP/1.1 200 OK
< Date: Sat, 24 May 2014 20:23:57 GMT
* Server Apache is not blacklisted
< Server: Apache
< Access-Control-Allow-Origin: *
< Vary: Accept-Encoding
< Content-Length: 141
< Content-Type: text/html
<
* Connection #0 to host posttestserver.com left intact
Err: [Error: Couldn't resolve host name]
Wtf
Lets test some other url with the exact same code:
B$ node test.js http://haxx.se/
* Hostname was NOT found in DNS cache
* Trying 80.67.6.50...
* Connected to haxx.se (80.67.6.50) port 80 (#0)
> POST / HTTP/1.1
Host: haxx.se
Accept: */*
Content-Length: 10
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 10 out of 10 bytes
< HTTP/1.1 301 Moved Permanently
< Date: Sat, 24 May 2014 20:26:32 GMT
* Server Apache/2.4.6 (Debian) is not blacklisted
< Server: Apache/2.4.6 (Debian)
< Location: http://www.haxx.se/
< Content-Length: 299
< Content-Type: text/html; charset=iso-8859-1
<
* Connection #0 to host haxx.se left intact
Err: [Error: URL using bad/illegal format or missing URL]
Ok, works! let's follow the redirect for the first request:
curl.setOpt( Curl.option.FOLLOWLOCATION, true );
B$ node test.js http://haxx.se/
* Hostname was NOT found in DNS cache
* Trying 80.67.6.50...
* Connected to haxx.se (80.67.6.50) port 80 (#0)
> POST / HTTP/1.1
Host: haxx.se
Accept: */*
Content-Length: 10
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 10 out of 10 bytes
< HTTP/1.1 301 Moved Permanently
< Date: Sat, 24 May 2014 20:25:04 GMT
* Server Apache/2.4.6 (Debian) is not blacklisted
< Server: Apache/2.4.6 (Debian)
< Location: http://www.haxx.se/
< Content-Length: 299
< Content-Type: text/html; charset=iso-8859-1
<
* Ignoring the response-body
* Connection #0 to host haxx.se left intact
* Issue another request to this URL: 'http://www.haxx.se/'
* Violate RFC 2616/10.3.2 and switch from POST to GET
* Hostname was NOT found in DNS cache
* Trying 80.67.6.50...
* Connected to www.haxx.se (80.67.6.50) port 80 (#1)
> GET / HTTP/1.1
Host: www.haxx.se
Accept: */*
< HTTP/1.1 200 OK
< Date: Sat, 24 May 2014 20:25:05 GMT
* Server Apache/2.4.6 (Debian) is not blacklisted
< Server: Apache/2.4.6 (Debian)
< Last-Modified: Mon, 11 Jun 2012 17:54:05 GMT
< ETag: "a7d-4c236093f038d"
< Accept-Ranges: bytes
< Content-Length: 2685
< Vary: Accept-Encoding
< Content-Type: text/html
<
* Connection #1 to host www.haxx.se left intact
the page html...
/usr/projects/vm/node/libcurl/test.js:514: Uncaught Error: Reset didn't worked.
Wtf again.
What is supposed to be happening here?
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-05-24