mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
CONNECT: read responses one byte at a time
... so that it doesn't read data that is actually coming from the remote. 2xx responses have no body from the proxy, that data is from the peer. Fixes #1132
This commit is contained in:
parent
c50b878c15
commit
3ea3518429
@ -328,9 +328,11 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
case 0: /* timeout */
|
case 0: /* timeout */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUGASSERT(ptr+BUFSIZE-nread <= data->state.buffer+BUFSIZE+1);
|
if(ptr >= &data->state.buffer[BUFSIZE]) {
|
||||||
result = Curl_read(conn, tunnelsocket, ptr, BUFSIZE-nread,
|
failf(data, "CONNECT response too large!");
|
||||||
&gotbytes);
|
return CURLE_RECV_ERROR;
|
||||||
|
}
|
||||||
|
result = Curl_read(conn, tunnelsocket, ptr, 1, &gotbytes);
|
||||||
if(result==CURLE_AGAIN)
|
if(result==CURLE_AGAIN)
|
||||||
continue; /* go loop yourself */
|
continue; /* go loop yourself */
|
||||||
else if(result)
|
else if(result)
|
||||||
@ -445,15 +447,6 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
if(cl) {
|
if(cl) {
|
||||||
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
|
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
|
||||||
" bytes of response-body\n", cl);
|
" bytes of response-body\n", cl);
|
||||||
|
|
||||||
/* remove the remaining chunk of what we already
|
|
||||||
read */
|
|
||||||
cl -= (gotbytes - i);
|
|
||||||
|
|
||||||
if(cl<=0)
|
|
||||||
/* if the whole thing was already read, we are done!
|
|
||||||
*/
|
|
||||||
keepon=FALSE;
|
|
||||||
}
|
}
|
||||||
else if(chunked_encoding) {
|
else if(chunked_encoding) {
|
||||||
CHUNKcode r;
|
CHUNKcode r;
|
||||||
@ -473,8 +466,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
|
|
||||||
/* now parse the chunked piece of data so that we can
|
/* now parse the chunked piece of data so that we can
|
||||||
properly tell when the stream ends */
|
properly tell when the stream ends */
|
||||||
r = Curl_httpchunk_read(conn, line_start+1,
|
r = Curl_httpchunk_read(conn, line_start+1, 1,
|
||||||
gotbytes -i, &gotbytes);
|
&gotbytes);
|
||||||
if(r == CHUNKE_STOP) {
|
if(r == CHUNKE_STOP) {
|
||||||
/* we're done reading chunks! */
|
/* we're done reading chunks! */
|
||||||
infof(data, "chunk reading DONE\n");
|
infof(data, "chunk reading DONE\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user