collectiveidea / tinder

Tinder is a Ruby API for interfacing with Campfire, the 37Signals chat application.
MIT License
256 stars 91 forks source link

Content-type header not being set #29

Closed gfeil closed 12 years ago

gfeil commented 12 years ago

According to the Campfire API documentation (http://developer.37signals.com/campfire/), it's expected for clients to set the Content-type header explicitly when sending JSON or XML requests. [I know, it's redundant, the content type should be inferred from the dot-extension of the request.] Occasionally a request that's properly authenticated, but rejected by Campfire for other reasons (possibly the account being disabled), a 302 redirect is returned with an HTML formatted message. This causes a lexical parsing error in YAJL. Following is a stack trace:

MultiJson::DecodeError: lexical error: invalid char in json text. You are being <a hr (right here) ------^ …8/gems/multi_json-1.0.3/lib/multi_json/engines/yajl.rb: 10:in parse' …8/gems/multi_json-1.0.3/lib/multi_json/engines/yajl.rb: 10:indecode' …undle/ruby/1.8/gems/multi_json-1.0.3/lib/multi_json.rb: 65:in decode' …ay_middleware-0.6.5/lib/faraday/response/parse_json.rb: 16:inparse' …le/ruby/1.8/gems/faraday-0.6.1/lib/faraday/response.rb: 17:in on_complete' …le/ruby/1.8/gems/faraday-0.6.1/lib/faraday/response.rb: 9:incall' …le/ruby/1.8/gems/faraday-0.6.1/lib/faraday/response.rb: 62:in on_complete' …le/ruby/1.8/gems/faraday-0.6.1/lib/faraday/response.rb: 8:incall' …le/ruby/1.8/gems/faraday-0.6.1/lib/faraday/response.rb: 8:in call' …uby/1.8/gems/faraday-0.6.1/lib/faraday/request/json.rb: 28:incall' …dle/ruby/1.8/gems/faraday-0.6.1/lib/faraday/request.rb: 88:in run' …dle/ruby/1.8/gems/faraday-0.6.1/lib/faraday/request.rb: 28:inrun' …/ruby/1.8/gems/faraday-0.6.1/lib/faraday/connection.rb: 170:in run_request' …/ruby/1.8/gems/faraday-0.6.1/lib/faraday/connection.rb: 64:inget' …le/ruby/1.8/gems/tinder-1.7.0/lib/tinder/connection.rb: 82:in get' …ndle/ruby/1.8/gems/tinder-1.7.0/lib/tinder/campfire.rb: 34:inrooms' …ndle/ruby/1.8/gems/tinder-1.7.0/lib/tinder/campfire.rb: 41:in `find_room_by_id'

gfeil commented 12 years ago

I heard back from 37signals, and it turns out they were always responding with HTML on authentication failures. This has been reported to be fixed, so this may not be as important now.

See this pull request: https://github.com/collectiveidea/tinder/pull/30

sferik commented 12 years ago

Can I close this now?

gfeil commented 12 years ago

I'm not working on Campfire integrations currently, so I'll go ahead and close this.