From ec24efda749df7513aaf994a9ef0d2b3c72eaed7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 7 Jan 2003 16:15:53 +0000 Subject: Simon Liu's HTTP200ALIASES-patch! --- lib/transfer.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'lib/transfer.c') diff --git a/lib/transfer.c b/lib/transfer.c index eca2cad7b..5ba6cd59c 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -162,6 +162,28 @@ static int fillbuffer(struct connectdata *conn, return nread; } +/* + * checkhttpprefix() + * + * Returns TRUE if member of the list matches prefix of string + */ +static bool +checkhttpprefix(struct SessionHandle *data, + const char *s) +{ + struct curl_slist *head = data->set.http200aliases; + + while (head) { + if (checkprefix(head->data, s)) + return TRUE; + head = head->next; + } + + if(checkprefix("HTTP/", s)) + return TRUE; + + return FALSE; +} CURLcode Curl_readwrite(struct connectdata *conn, bool *done) @@ -287,7 +309,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, k->hbuflen += nread; if (!k->headerline && (k->hbuflen>5)) { /* make a first check that this looks like a HTTP header */ - if(!checkprefix("HTTP/", data->state.headerbuff)) { + if(!checkhttpprefix(data, data->state.headerbuff)) { /* this is not the beginning of a HTTP first header line */ k->header = FALSE; k->badheader = HEADER_ALLBAD; @@ -341,7 +363,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, if(!k->headerline) { /* the first read header */ if((k->hbuflen>5) && - !checkprefix("HTTP/", data->state.headerbuff)) { + !checkhttpprefix(data, data->state.headerbuff)) { /* this is not the beginning of a HTTP first header line */ k->header = FALSE; k->badheader = HEADER_PARTHEADER; @@ -468,6 +490,18 @@ CURLcode Curl_readwrite(struct connectdata *conn, */ nc=sscanf (k->p, " HTTP %3d", &k->httpcode); k->httpversion = 10; + + /* If user has set option HTTP200ALIASES, + compare header line against list of aliases + */ + if (!nc) { + if (checkhttpprefix(data, k->p)) { + nc = 1; + k->httpcode = 200; + k->httpversion = + (data->set.httpversion==CURL_HTTP_VERSION_1_0)? 10 : 11; + } + } } if (nc) { -- cgit v1.2.3