Add accept-encoding header - fixing "403 Forbidden" #3

Merged
merged 2 commits into from Sep 10, 2013

2 participants

@bartoszkopinski

This fixes 403 Forbidden responses for me.

{"message"=>"<html>",
 "sessionid"=>"\n<head><title>403 Forbidden</title></head>",
 "logurl"=>"\n<body bgcolor=\"white\">",
 "vText8"=>"\n<center><h1>403 Forbidden</h1></center>",
 "vText7"=>"\n<hr><center>nginx/0.7.67</center>",
 "vText6"=>"\n</body>",
 "vText5"=>"\n</html>",
 "vText4"=>"\n",
 "vText3"=>nil,
 "vText2"=>nil,
 "prevref"=>nil,
 nil=>nil,
 "emotionalhistory"=>nil,
 "ttsLocMP3"=>nil,
 "ttsLocTXT"=>nil,
 "ttsLocTXT3"=>nil,
 "ttsText"=>nil,
 "lineref"=>nil,
 "lineURL"=>nil,
 "linePOST"=>nil,
 "lineChoices"=>nil,
 "lineChoicesAbbrev"=>nil,
 "typingData"=>nil,
 "divert"=>nil}
@benmanns
Owner

Thanks for this. It looks like Cleverbot has updated their protocol a bit since I last took a look at it. I'll review the protocol and see what needs to be updated.

Were you getting 403s sporadically or on every request?

@benmanns
Owner

Also, would you mind changing x-gzip to gzip?

@bartoszkopinski

Hey,
I was getting them on every request.
Looks like it's still not perfect though, I'm getting 'DENIED' randomly now.
Only 'deflate' seems to be working every time, but I'm having a hard time getting httparty to encode the response properly.

pry> post(PATH, :body => body, :headers => { 'Accept-Encoding' => 'deflate' })
Zlib::DataError: incorrect header check
from /.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http/response.rb:357:in `finish'

I can see the response is correct but it's raising the exception on parse. Any thoughts on this? Are you getting 403s as well?

@bartoszkopinski

Ok, changed to gzip. Not sure about these 'DENIED' responses, it might have been not related.

@benmanns benmanns merged commit 390eeb1 into benmanns:master Sep 10, 2013

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment