mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Simon Liu's HTTP200ALIASES-patch!
This commit is contained in:
parent
7f0f10e498
commit
ec24efda74
@ -616,6 +616,9 @@ typedef enum {
|
|||||||
/* Set pointer to private data */
|
/* Set pointer to private data */
|
||||||
CINIT(PRIVATE, OBJECTPOINT, 103),
|
CINIT(PRIVATE, OBJECTPOINT, 103),
|
||||||
|
|
||||||
|
/* Set aliases for HTTP 200 in the HTTP Response header */
|
||||||
|
CINIT(HTTP200ALIASES, OBJECTPOINT, 104),
|
||||||
|
|
||||||
CURLOPT_LASTENTRY /* the last unused */
|
CURLOPT_LASTENTRY /* the last unused */
|
||||||
} CURLoption;
|
} CURLoption;
|
||||||
|
|
||||||
|
@ -162,6 +162,28 @@ static int fillbuffer(struct connectdata *conn,
|
|||||||
return nread;
|
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,
|
CURLcode Curl_readwrite(struct connectdata *conn,
|
||||||
bool *done)
|
bool *done)
|
||||||
@ -287,7 +309,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
k->hbuflen += nread;
|
k->hbuflen += nread;
|
||||||
if (!k->headerline && (k->hbuflen>5)) {
|
if (!k->headerline && (k->hbuflen>5)) {
|
||||||
/* make a first check that this looks like a HTTP header */
|
/* 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 */
|
/* this is not the beginning of a HTTP first header line */
|
||||||
k->header = FALSE;
|
k->header = FALSE;
|
||||||
k->badheader = HEADER_ALLBAD;
|
k->badheader = HEADER_ALLBAD;
|
||||||
@ -341,7 +363,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
if(!k->headerline) {
|
if(!k->headerline) {
|
||||||
/* the first read header */
|
/* the first read header */
|
||||||
if((k->hbuflen>5) &&
|
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 */
|
/* this is not the beginning of a HTTP first header line */
|
||||||
k->header = FALSE;
|
k->header = FALSE;
|
||||||
k->badheader = HEADER_PARTHEADER;
|
k->badheader = HEADER_PARTHEADER;
|
||||||
@ -468,6 +490,18 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
nc=sscanf (k->p, " HTTP %3d", &k->httpcode);
|
nc=sscanf (k->p, " HTTP %3d", &k->httpcode);
|
||||||
k->httpversion = 10;
|
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) {
|
if (nc) {
|
||||||
|
@ -1095,6 +1095,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
|
|||||||
data->set.private = va_arg(param, char *);
|
data->set.private = va_arg(param, char *);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CURLOPT_HTTP200ALIASES:
|
||||||
|
/*
|
||||||
|
* Set a list of aliases for HTTP 200 in response header
|
||||||
|
*/
|
||||||
|
data->set.http200aliases = va_arg(param, struct curl_slist *);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* unknown tag and its companion, just ignore: */
|
/* unknown tag and its companion, just ignore: */
|
||||||
return CURLE_FAILED_INIT; /* correct this */
|
return CURLE_FAILED_INIT; /* correct this */
|
||||||
|
@ -716,6 +716,8 @@ struct UserDefined {
|
|||||||
|
|
||||||
char *private; /* Private data */
|
char *private; /* Private data */
|
||||||
|
|
||||||
|
struct curl_slist *http200aliases; /* linked list of aliases for http200 */
|
||||||
|
|
||||||
/* Here follows boolean settings that define how to behave during
|
/* Here follows boolean settings that define how to behave during
|
||||||
this session. They are STATIC, set by libcurl users or at least initially
|
this session. They are STATIC, set by libcurl users or at least initially
|
||||||
and they don't change during operations. */
|
and they don't change during operations. */
|
||||||
|
Loading…
Reference in New Issue
Block a user