{"action":"created","issue":{"url":"https://api.github.com/repos/lostisland/faraday/issues/455","labels_url":"https://api.github.com/repos/lostisland/faraday/issues/455/labels{/name}","comments_url":"https://api.github.com/repos/lostisland/faraday/issues/455/comments","events_url":"https://api.github.com/repos/lostisland/faraday/issues/455/events","html_url":"https://github.com/lostisland/faraday/issues/455","id":53939148,"number":455,"title":"Middleware cripple requests","user":{"login":"t3hk0d3","id":86416,"avatar_url":"https://avatars.githubusercontent.com/u/86416?v=3","gravatar_id":"","url":"https://api.github.com/users/t3hk0d3","html_url":"https://github.com/t3hk0d3","followers_url":"https://api.github.com/users/t3hk0d3/followers","following_url":"https://api.github.com/users/t3hk0d3/following{/other_user}","gists_url":"https://api.github.com/users/t3hk0d3/gists{/gist_id}","starred_url":"https://api.github.com/users/t3hk0d3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t3hk0d3/subscriptions","organizations_url":"https://api.github.com/users/t3hk0d3/orgs","repos_url":"https://api.github.com/users/t3hk0d3/repos","events_url":"https://api.github.com/users/t3hk0d3/events{/privacy}","received_events_url":"https://api.github.com/users/t3hk0d3/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-10T01:46:56Z","updated_at":"2015-10-08T10:22:34Z","closed_at":"2015-01-11T06:28:15Z","body":"## Without any middleware\r\n\r\n**Everything working as expected**\r\n```\r\n[37] pry(main)>  p = Faraday.new(\"http://192.168.5.4:8112\")\r\n=> #<Faraday::Connection:0x007fd461259c88\r\n @builder=#<Faraday::RackBuilder:0x007fd4612598f0 @handlers=[Faraday::Request::UrlEncoded, Faraday::Adapter::NetHttp]>,\r\n @default_parallel_manager=nil,\r\n @headers={\"User-Agent\"=>\"Faraday v0.9.1\"},\r\n @options=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,\r\n @parallel_manager=nil,\r\n @params={},\r\n @proxy=nil,\r\n @ssl=\r\n  #<struct Faraday::SSLOptions\r\n   verify=nil,\r\n   ca_file=nil,\r\n   ca_path=nil,\r\n   verify_mode=nil,\r\n   cert_store=nil,\r\n   client_cert=nil,\r\n   client_key=nil,\r\n   certificate=nil,\r\n   private_key=nil,\r\n   verify_depth=nil,\r\n   version=nil>,\r\n @url_prefix=#<URI::HTTP:0x007fd461258c48 URL:http://192.168.5.4:8112/>>\r\n[38] pry(main)> p.post '/json', \"{\\\"id\\\": 0, \\\"method\\\":\\\"auth.login\\\", \\\"params\\\":[\\\"password\\\"]}\"\r\n=> #<Faraday::Response:0x007fd4611d3bd8\r\n @env=\r\n  #<struct Faraday::Env\r\n   method=:post,\r\n   body=\"{\\\"id\\\": 0, \\\"result\\\": false, \\\"error\\\": null}\",\r\n   url=#<URI::HTTP:0x007fd4611e21d8 URL:http://192.168.5.4:8112/json>,\r\n   request=\r\n    #<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,\r\n   request_headers={\"User-Agent\"=>\"Faraday v0.9.1\", \"Content-Type\"=>\"application/x-www-form-urlencoded\"},\r\n   ssl=\r\n    #<struct Faraday::SSLOptions\r\n     verify=nil,\r\n     ca_file=nil,\r\n     ca_path=nil,\r\n     verify_mode=nil,\r\n     cert_store=nil,\r\n     client_cert=nil,\r\n     client_key=nil,\r\n     certificate=nil,\r\n     private_key=nil,\r\n     verify_depth=nil,\r\n     version=nil>,\r\n   parallel_manager=nil,\r\n   params=nil,\r\n   response=nil,\r\n   response_headers=\r\n    {\"transfer-encoding\"=>\"chunked\",\r\n     \"date\"=>\"Sat, 10 Jan 2015 01:47:43 GMT\",\r\n     \"connection\"=>\"close\",\r\n     \"content-type\"=>\"application/x-json\",\r\n     \"server\"=>\"TwistedWeb/12.0.0\"},\r\n   status=200>,\r\n @on_complete_callbacks=[]>\r\n```\r\n\r\n## With Logger middleware:\r\n\r\n**Probably does not make any reponse. Crash on dumping headers (they are nil)**\r\n```\r\n[39] pry(main)> p = Faraday.new(\"http://192.168.5.4:8112\") { |f| f.response :logger }\r\n=> #<Faraday::Connection:0x007fd460a44f98\r\n @builder=#<Faraday::RackBuilder:0x007fd460a44930 @handlers=[Faraday::Response::Logger]>,\r\n @default_parallel_manager=nil,\r\n @headers={\"User-Agent\"=>\"Faraday v0.9.1\"},\r\n @options=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,\r\n @parallel_manager=nil,\r\n @params={},\r\n @proxy=nil,\r\n @ssl=\r\n  #<struct Faraday::SSLOptions\r\n   verify=nil,\r\n   ca_file=nil,\r\n   ca_path=nil,\r\n   verify_mode=nil,\r\n   cert_store=nil,\r\n   client_cert=nil,\r\n   client_key=nil,\r\n   certificate=nil,\r\n   private_key=nil,\r\n   verify_depth=nil,\r\n   version=nil>,\r\n @url_prefix=#<URI::HTTP:0x007fd460a44520 URL:http://192.168.5.4:8112/>>\r\n[40] pry(main)> p.post '/json', \"{\\\"id\\\": 0, \\\"method\\\":\\\"auth.login\\\", \\\"params\\\":[\\\"password\\\"]}\"\r\nI, [2015-01-10T04:48:16.268374 #77388]  INFO -- : post http://192.168.5.4:8112/json\r\nD, [2015-01-10T04:48:16.268467 #77388] DEBUG -- request: User-Agent: \"Faraday v0.9.1\"\r\nI, [2015-01-10T04:48:16.268619 #77388]  INFO -- Status: \r\nNoMethodError: undefined method `map' for nil:NilClass\r\nfrom /Users/tehkode/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/faraday-0.9.1/lib/faraday/response/logger.rb:36:in `dump_headers'\r\n```\r\n\r\n## With JSON request middleware\r\n\r\n**Does not make any request. Return request as response**\r\n\r\n```\r\n[41] pry(main)> p = Faraday.new(\"http://192.168.5.4:8112\") { |f| f.request :json }\r\n=> #<Faraday::Connection:0x007fd460c68e78\r\n @builder=#<Faraday::RackBuilder:0x007fd460c68a40 @handlers=[FaradayMiddleware::EncodeJson]>,\r\n @default_parallel_manager=nil,\r\n @headers={\"User-Agent\"=>\"Faraday v0.9.1\"},\r\n @options=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,\r\n @parallel_manager=nil,\r\n @params={},\r\n @proxy=nil,\r\n @ssl=\r\n  #<struct Faraday::SSLOptions\r\n   verify=nil,\r\n   ca_file=nil,\r\n   ca_path=nil,\r\n   verify_mode=nil,\r\n   cert_store=nil,\r\n   client_cert=nil,\r\n   client_key=nil,\r\n   certificate=nil,\r\n   private_key=nil,\r\n   verify_depth=nil,\r\n   version=nil>,\r\n @url_prefix=#<URI::HTTP:0x007fd460c68770 URL:http://192.168.5.4:8112/>>\r\n[42] pry(main)> p.post '/json', \"{\\\"id\\\": 0, \\\"method\\\":\\\"auth.login\\\", \\\"params\\\":[\\\"password\\\"]}\"\r\n=> #<Faraday::Response:0x007fd460b922b0\r\n @env=\r\n  #<struct Faraday::Env\r\n   method=:post,\r\n   body=\"{\\\"id\\\": 0, \\\"method\\\":\\\"auth.login\\\", \\\"params\\\":[\\\"torrent\\\"]}\",\r\n   url=#<URI::HTTP:0x007fd460b92c38 URL:http://192.168.5.4:8112/json>,\r\n   request=\r\n    #<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,\r\n   request_headers={\"User-Agent\"=>\"Faraday v0.9.1\", \"Content-Type\"=>\"application/json\"},\r\n   ssl=\r\n    #<struct Faraday::SSLOptions\r\n     verify=nil,\r\n     ca_file=nil,\r\n     ca_path=nil,\r\n     verify_mode=nil,\r\n     cert_store=nil,\r\n     client_cert=nil,\r\n     client_key=nil,\r\n     certificate=nil,\r\n     private_key=nil,\r\n     verify_depth=nil,\r\n     version=nil>,\r\n   parallel_manager=nil,\r\n   params=nil,\r\n   response=nil,\r\n   response_headers=nil,\r\n   status=nil>,\r\n @on_complete_callbacks=[]>\r\n```\r\n\r\n## With JSON response middleware\r\n\r\n```\r\n[43] pry(main)> p = Faraday.new(\"http://192.168.5.4:8112\") { |f| f.response :json }\r\n=> #<Faraday::Connection:0x007fd4611eaae0\r\n @builder=#<Faraday::RackBuilder:0x007fd4611ea680 @handlers=[FaradayMiddleware::ParseJson]>,\r\n @default_parallel_manager=nil,\r\n @headers={\"User-Agent\"=>\"Faraday v0.9.1\"},\r\n @options=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,\r\n @parallel_manager=nil,\r\n @params={},\r\n @proxy=nil,\r\n @ssl=\r\n  #<struct Faraday::SSLOptions\r\n   verify=nil,\r\n   ca_file=nil,\r\n   ca_path=nil,\r\n   verify_mode=nil,\r\n   cert_store=nil,\r\n   client_cert=nil,\r\n   client_key=nil,\r\n   certificate=nil,\r\n   private_key=nil,\r\n   verify_depth=nil,\r\n   version=nil>,\r\n @url_prefix=#<URI::HTTP:0x007fd4611ea360 URL:http://192.168.5.4:8112/>>\r\n[44] pry(main)> p.post '/json', \"{\\\"id\\\": 0, \\\"method\\\":\\\"auth.login\\\", \\\"params\\\":[\\\"torrent\\\"]}\"\r\nNoMethodError: undefined method `[]' for nil:NilClass\r\nfrom /Users/tehkode/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/faraday_middleware-0.9.1/lib/faraday_middleware/response_middleware.rb:59:in `response_type'\r\n```"},"comment":{"url":"https://api.github.com/repos/lostisland/faraday/issues/comments/146487476","html_url":"https://github.com/lostisland/faraday/issues/455#issuecomment-146487476","issue_url":"https://api.github.com/repos/lostisland/faraday/issues/455","id":146487476,"user":{"login":"pferdefleisch","id":175984,"avatar_url":"https://avatars.githubusercontent.com/u/175984?v=3","gravatar_id":"","url":"https://api.github.com/users/pferdefleisch","html_url":"https://github.com/pferdefleisch","followers_url":"https://api.github.com/users/pferdefleisch/followers","following_url":"https://api.github.com/users/pferdefleisch/following{/other_user}","gists_url":"https://api.github.com/users/pferdefleisch/gists{/gist_id}","starred_url":"https://api.github.com/users/pferdefleisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pferdefleisch/subscriptions","organizations_url":"https://api.github.com/users/pferdefleisch/orgs","repos_url":"https://api.github.com/users/pferdefleisch/repos","events_url":"https://api.github.com/users/pferdefleisch/events{/privacy}","received_events_url":"https://api.github.com/users/pferdefleisch/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T10:22:34Z","updated_at":"2015-10-08T10:22:34Z","body":"@mislav another option is to raise a descriptive exception if there is no adapter set in the block\r\n\r\nI agree that the current behavior is pretty confusing."}}