Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting post_body to nil does not reset data posted in http(:GET) #133

Closed
geronime opened this issue Oct 28, 2012 · 5 comments · Fixed by #143
Closed

Setting post_body to nil does not reset data posted in http(:GET) #133

geronime opened this issue Oct 28, 2012 · 5 comments · Fixed by #143

Comments

@geronime
Copy link
Contributor

Hello,

after resetting post_body to nil the next http(:GET) request still sends the old POST data:

> c = Curl::Easy.new 'http://127.0.0.1:10000'
=> #<Curl::Easy http://127.0.0.1:10000>
> c.http :GET
Curl::Err::GotNothingError: Curl::Err::GotNothingError
from /home/geronime/.../curb-0.8.1/lib/curl/easy.rb:60:in `perform'

Netcat output:

$ nc -lp 10000
GET / HTTP/1.1
Host: 127.0.0.1:10000
Accept: */*

^C

OK. Set post_body and repeat:

> c.post_body = 'param=value'
=> "param=value"
> c.http :GET
Curl::Err::GotNothingError: Curl::Err::GotNothingError
from /home/geronime/.../curb-0.8.1/lib/curl/easy.rb:60:in `perform'

nc output:

$ nc -lp 10000
GET / HTTP/1.1
Host: 127.0.0.1:10000
Accept: */*
Content-Length: 11
Content-Type: application/x-www-form-urlencoded

param=value^C

OK. Reset post_body to nil and perform again:

> c.post_body = nil
=> nil
> c.http :GET
Curl::Err::GotNothingError: Curl::Err::GotNothingError
from /home/geronime/.../curb-0.8.1/lib/curl/easy.rb:60:in `perform'

nc output:

$ nc -lp 10000
GET / HTTP/1.1
Host: 127.0.0.1:10000
Accept: */*
Content-Length: 11
Content-Type: application/x-www-form-urlencoded

param=value^C

Not OK, post data sent even after the post_body was reset to nil. Reset to empty data and retry:

> c.post_body = ''
=> ""
> c.http :GET
Curl::Err::GotNothingError: Curl::Err::GotNothingError
from /home/geronime/.../curb-0.8.1/lib/curl/easy.rb:60:in `perform'

nc output:

$ nc -lp 10000
GET / HTTP/1.1
Host: 127.0.0.1:10000
Accept: */*
Content-Length: 0
Content-Type: application/x-www-form-urlencoded

^C

Correct, can be used as workaround.

Could you please fix that setting post_body=nil clears the data posted?

Thanks,

geronime

@geronime
Copy link
Contributor Author

Hello, any update on this one?

@JaromirDvoracek
Copy link

Nice bug, fix would be useful!

@taf2
Copy link
Owner

taf2 commented Jan 10, 2013

try:

   easy.reset

?

@geronime
Copy link
Contributor Author

Correct me if I am wrong, but would it not reset settings (i.e. timeout) and cookies as well? That is not what I want.
I need to reset just post body of the handle.

geronime added a commit to geronime/curb that referenced this issue Feb 6, 2013
easy.post_body = nil sets CURLOPT_HTTPGET to 1
@geronime
Copy link
Contributor Author

geronime commented Feb 6, 2013

Fix done - it is necessary to set CURLOPT_HTTPGET to 1:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPGET

@taf2 taf2 closed this as completed in 0d11a1f Feb 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants