igrigorik / em-http-request

Asynchronous HTTP Client (EventMachine + Ruby)
1.22k stars 222 forks source link

POST request bug? #271

Closed sid-code closed 10 years ago

sid-code commented 10 years ago

http://stackoverflow.com/questions/25164272/simple-post-request-failing-with-em-http-request

Basically, when I try the equivalent of curl --data 'start=y&icognoid=wsf&fno=0&sub=Say&islearning=1&cleanslate=false&stimulus=!!!%2‌​0there%20was%20an%20error%20!!!&icognocheck=af71393ce00d9126a247df2f53948e79' http://www.cleverbot.com/webservicemin/ in em-http-request, it calls fail even though the curl displays the correct response from the server.

Here is the code I had as the equlvaient of the curl:

require 'eventmachine'
require 'em-http-request'

uri  = 'http://www.cleverbot.com/webservicemin/'
query = 'start=y&icognoid=wsf&fno=0&sub=Say&islearning=1&cleanslate=false&stimulus=!!!%20there%20was%20an%20error%20!!!&icognocheck=af71393ce00d9126a247df2f53948e79'

EM.run do

  http = EM::HttpRequest.new(uri).post(query: query)
  http.callback { puts http.response; EM.stop }
  http.errback { puts 'There was an error'; EM.stop }
end

There was an error is printed.

igrigorik commented 10 years ago

Followed up on SF.