{"action":"created","issue":{"url":"https://api.github.com/repos/excon/excon/issues/565","repository_url":"https://api.github.com/repos/excon/excon","labels_url":"https://api.github.com/repos/excon/excon/issues/565/labels{/name}","comments_url":"https://api.github.com/repos/excon/excon/issues/565/comments","events_url":"https://api.github.com/repos/excon/excon/issues/565/events","html_url":"https://github.com/excon/excon/issues/565","id":151931629,"number":565,"title":"Reads are occurring one byte at a time","user":{"login":"colinmarc","id":821775,"avatar_url":"https://avatars.githubusercontent.com/u/821775?v=3","gravatar_id":"","url":"https://api.github.com/users/colinmarc","html_url":"https://github.com/colinmarc","followers_url":"https://api.github.com/users/colinmarc/followers","following_url":"https://api.github.com/users/colinmarc/following{/other_user}","gists_url":"https://api.github.com/users/colinmarc/gists{/gist_id}","starred_url":"https://api.github.com/users/colinmarc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinmarc/subscriptions","organizations_url":"https://api.github.com/users/colinmarc/orgs","repos_url":"https://api.github.com/users/colinmarc/repos","events_url":"https://api.github.com/users/colinmarc/events{/privacy}","received_events_url":"https://api.github.com/users/colinmarc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-29T17:48:23Z","updated_at":"2016-04-29T17:52:12Z","closed_at":null,"body":"I started an http server on ubuntu 12.04 with `python -m SimpleHTTPServer 8080` and then strace'd this test script:\r\n\r\n```\r\nrequire 'excon'\r\n\r\nloop do\r\n  puts \"press enter to continue\"\r\n  gets\r\n  Excon.get(\"http://localhost:8080/foo.txt\")\r\nend\r\n```\r\n\r\nExcon seems to be calling `read` for one byte at a time:\r\n\r\n```\r\nread(7, \"H\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"T\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"T\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"P\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"/\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"1\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \".\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"0\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \" \", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"2\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"0\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"0\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \" \", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"O\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"K\", 1)                         = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"\\r\", 1)                        = 1\r\nfcntl(7, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)\r\nread(7, \"\\n\", 1)                        = 1\r\n```\r\n\r\nI'll dig into the code and see if I can figure out a fix, but figured I should open an issue first. =)"},"comment":{"url":"https://api.github.com/repos/excon/excon/issues/comments/215829172","html_url":"https://github.com/excon/excon/issues/565#issuecomment-215829172","issue_url":"https://api.github.com/repos/excon/excon/issues/565","id":215829172,"user":{"login":"geemus","id":4138,"avatar_url":"https://avatars.githubusercontent.com/u/4138?v=3","gravatar_id":"","url":"https://api.github.com/users/geemus","html_url":"https://github.com/geemus","followers_url":"https://api.github.com/users/geemus/followers","following_url":"https://api.github.com/users/geemus/following{/other_user}","gists_url":"https://api.github.com/users/geemus/gists{/gist_id}","starred_url":"https://api.github.com/users/geemus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geemus/subscriptions","organizations_url":"https://api.github.com/users/geemus/orgs","repos_url":"https://api.github.com/users/geemus/repos","events_url":"https://api.github.com/users/geemus/events{/privacy}","received_events_url":"https://api.github.com/users/geemus/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T17:52:12Z","updated_at":"2016-04-29T17:52:12Z","body":"As they are nonblocking writes, it will return as soon as possible. So it may have to do with the way the server is responding, more than what excon is doing (I would expect it to actually try to get as much as 1MB as a time by default, but due to non-blocking nature it will settle for whatever it can get)."}}