sbisbee/sag — Issue #41: Attachment response handling lags if no trailing new line
Author: sbisbee
Created: 2011-12-27 16:44:17+00:00
State: open
Labels: bug

Originally reported by @skyshard in issue #32:

"I've also noted that retrieving an attachment that doesn't have a new line on the last line will cause the fgets() call to wait until it times out"

"or the attachment retrieval case, you could fix it by changing:
`$line = fgets($sock);`
to
`$line = fgets($sock, $response->headers->{'Content-Length'} - $bodyLength + 1);`
(and keep track of $bodyLength when concatenating to $response->body, instead of recounting the whole thing each iteration)

(edit- it turns out that a large max read length makes the read loop quite slow. may be worth just doing it for the last KB, or 8KB, etc)"