mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
http_proxy: simplify CONNECT response reading
Since it now reads responses one byte a time, a loop could be removed and it is no longer limited to get the whole response within 16K, it is now instead only limited to 16K maximum header line lengths.
This commit is contained in:
parent
3b77aa6b28
commit
74595b223d
@ -18,7 +18,6 @@ problems may have been fixed or changed somewhat since this was written!
|
||||
1.4 multipart formposts file name encoding
|
||||
1.5 Expect-100 meets 417
|
||||
1.6 Unnecessary close when 401 received waiting for 100
|
||||
1.7 CONNECT response larger than 16KB
|
||||
1.8 DNS timing is wrong for HTTP redirects
|
||||
1.9 HTTP/2 frames while in the connection pool kill reuse
|
||||
1.10 Strips trailing dot from host name
|
||||
@ -144,13 +143,6 @@ problems may have been fixed or changed somewhat since this was written!
|
||||
waiting for the the 100-continue response.
|
||||
https://curl.haxx.se/mail/lib-2008-08/0462.html
|
||||
|
||||
1.7 CONNECT response larger than 16KB
|
||||
|
||||
If a CONNECT response-headers are larger than BUFSIZE (16KB) when the
|
||||
connection is meant to be kept alive (like for NTLM proxy auth), the function
|
||||
will return prematurely and will confuse the rest of the HTTP protocol
|
||||
code. This should be very rare.
|
||||
|
||||
1.8 DNS timing is wrong for HTTP redirects
|
||||
|
||||
When extracting timing information after HTTP redirects, only the last
|
||||
|
@ -351,14 +351,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* We got a whole chunk of data, which can be anything from one
|
||||
* byte to a set of lines and possibly just a piece of the last
|
||||
* line.
|
||||
*/
|
||||
int i;
|
||||
|
||||
nread += gotbytes;
|
||||
/* We got a byte of data */
|
||||
nread++;
|
||||
|
||||
if(keepon > TRUE) {
|
||||
/* This means we are currently ignoring a response-body */
|
||||
@ -368,7 +362,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
if(cl) {
|
||||
/* A Content-Length based body: simply count down the counter
|
||||
and make sure to break out of the loop when we're done! */
|
||||
cl -= gotbytes;
|
||||
cl--;
|
||||
if(cl<=0) {
|
||||
keepon = FALSE;
|
||||
break;
|
||||
@ -382,7 +376,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
|
||||
/* now parse the chunked piece of data so that we can
|
||||
properly tell when the stream ends */
|
||||
r = Curl_httpchunk_read(conn, ptr, gotbytes, &tookcareof);
|
||||
r = Curl_httpchunk_read(conn, ptr, 1, &tookcareof);
|
||||
if(r == CHUNKE_STOP) {
|
||||
/* we're done reading chunks! */
|
||||
infof(data, "chunk reading DONE\n");
|
||||
@ -395,16 +389,13 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
tookcareof);
|
||||
}
|
||||
}
|
||||
else
|
||||
for(i = 0; i < gotbytes; ptr++, i++) {
|
||||
else {
|
||||
perline++; /* amount of bytes in this line so far */
|
||||
if(*ptr == 0x0a) {
|
||||
char letter;
|
||||
int writetype;
|
||||
|
||||
/* convert from the network encoding */
|
||||
result = Curl_convert_from_network(data, line_start,
|
||||
perline);
|
||||
result = Curl_convert_from_network(data, line_start, perline);
|
||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||
if(result)
|
||||
return result;
|
||||
@ -455,13 +446,11 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
attention so that this is cleared again when this
|
||||
function returns! */
|
||||
k->ignorebody = TRUE;
|
||||
infof(data, "%zd bytes of chunk left\n", gotbytes-i);
|
||||
|
||||
if(line_start[1] == '\n') {
|
||||
/* this can only be a LF if the letter at index 0
|
||||
was a CR */
|
||||
line_start++;
|
||||
i++;
|
||||
}
|
||||
|
||||
/* now parse the chunked piece of data so that we can
|
||||
@ -487,22 +476,13 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
keepon=FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
keepon = FALSE;
|
||||
if(200 == data->info.httpproxycode) {
|
||||
if(gotbytes - (i+1))
|
||||
failf(data, "Proxy CONNECT followed by %zd bytes "
|
||||
"of opaque data. Data ignored (known bug #39)",
|
||||
gotbytes - (i+1));
|
||||
}
|
||||
}
|
||||
/* we did the full CONNECT treatment, go to COMPLETE */
|
||||
conn->tunnel_state[sockindex] = TUNNEL_COMPLETE;
|
||||
break; /* breaks out of for-loop, not switch() */
|
||||
}
|
||||
|
||||
/* keep a backup of the position we are about to blank */
|
||||
letter = line_start[perline];
|
||||
line_start[perline]=0; /* zero terminate the buffer */
|
||||
if((checkprefix("WWW-Authenticate:", line_start) &&
|
||||
(401 == k->httpcode)) ||
|
||||
@ -562,12 +542,13 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
/* store the HTTP code from the proxy */
|
||||
data->info.httpproxycode = k->httpcode;
|
||||
}
|
||||
/* put back the letter we blanked out before */
|
||||
line_start[perline]= letter;
|
||||
|
||||
perline=0; /* line starts over here */
|
||||
line_start = ptr+1; /* this skips the zero byte we wrote */
|
||||
ptr = data->state.buffer;
|
||||
line_start = ptr;
|
||||
}
|
||||
else /* not end of header line */
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user