http: Minor update based on CODE_STYLE guidelines

This commit is contained in:
Steve Holme 2016-03-24 06:35:23 +00:00
parent 726ae07b07
commit 96fff9f6b5
1 changed files with 25 additions and 27 deletions

View File

@ -148,7 +148,6 @@ const struct Curl_handler Curl_handler_https = {
}; };
#endif #endif
CURLcode Curl_http_setup_conn(struct connectdata *conn) CURLcode Curl_http_setup_conn(struct connectdata *conn)
{ {
/* allocate the HTTP-specific struct for the SessionHandle, only to survive /* allocate the HTTP-specific struct for the SessionHandle, only to survive
@ -185,6 +184,7 @@ char *Curl_checkheaders(const struct connectdata *conn,
if(Curl_raw_nequal(head->data, thisheader, thislen)) if(Curl_raw_nequal(head->data, thisheader, thislen))
return head->data; return head->data;
} }
return NULL; return NULL;
} }
@ -196,7 +196,6 @@ char *Curl_checkheaders(const struct connectdata *conn,
* It takes a connectdata struct as input instead of the SessionHandle simply * It takes a connectdata struct as input instead of the SessionHandle simply
* to know if this is a proxy request or not, as it then might check a * to know if this is a proxy request or not, as it then might check a
* different header list. * different header list.
*
*/ */
char *Curl_checkProxyheaders(const struct connectdata *conn, char *Curl_checkProxyheaders(const struct connectdata *conn,
const char *thisheader) const char *thisheader)
@ -205,12 +204,13 @@ char *Curl_checkProxyheaders(const struct connectdata *conn,
size_t thislen = strlen(thisheader); size_t thislen = strlen(thisheader);
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
for(head = (conn->bits.proxy && data->set.sep_headers)? for(head = (conn->bits.proxy && data->set.sep_headers) ?
data->set.proxyheaders:data->set.headers; data->set.proxyheaders : data->set.headers;
head; head=head->next) { head; head=head->next) {
if(Curl_raw_nequal(head->data, thisheader, thislen)) if(Curl_raw_nequal(head->data, thisheader, thislen))
return head->data; return head->data;
} }
return NULL; return NULL;
} }
@ -309,7 +309,7 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy)
free(*userp); free(*userp);
*userp = aprintf("%sAuthorization: Basic %s\r\n", *userp = aprintf("%sAuthorization: Basic %s\r\n",
proxy?"Proxy-":"", proxy ? "Proxy-" : "",
authorization); authorization);
free(authorization); free(authorization);
if(!*userp) if(!*userp)
@ -528,7 +528,6 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
return result; return result;
} }
} }
else if((data->req.httpcode < 300) && else if((data->req.httpcode < 300) &&
(!data->state.authhost.done) && (!data->state.authhost.done) &&
conn->bits.authneg) { conn->bits.authneg) {
@ -553,7 +552,6 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
return result; return result;
} }
/* /*
* Output the correct authentication header depending on the auth type * Output the correct authentication header depending on the auth type
* and whether or not it is to a proxy. * and whether or not it is to a proxy.
@ -584,7 +582,7 @@ output_auth_headers(struct connectdata *conn,
negdata->state = GSS_AUTHNONE; negdata->state = GSS_AUTHNONE;
if((authstatus->picked == CURLAUTH_NEGOTIATE) && if((authstatus->picked == CURLAUTH_NEGOTIATE) &&
negdata->context && !GSS_ERROR(negdata->status)) { negdata->context && !GSS_ERROR(negdata->status)) {
auth="Negotiate"; auth = "Negotiate";
result = Curl_output_negotiate(conn, proxy); result = Curl_output_negotiate(conn, proxy);
if(result) if(result)
return result; return result;
@ -595,7 +593,7 @@ output_auth_headers(struct connectdata *conn,
#endif #endif
#ifdef USE_NTLM #ifdef USE_NTLM
if(authstatus->picked == CURLAUTH_NTLM) { if(authstatus->picked == CURLAUTH_NTLM) {
auth="NTLM"; auth = "NTLM";
result = Curl_output_ntlm(conn, proxy); result = Curl_output_ntlm(conn, proxy);
if(result) if(result)
return result; return result;
@ -613,7 +611,7 @@ output_auth_headers(struct connectdata *conn,
#endif #endif
#ifndef CURL_DISABLE_CRYPTO_AUTH #ifndef CURL_DISABLE_CRYPTO_AUTH
if(authstatus->picked == CURLAUTH_DIGEST) { if(authstatus->picked == CURLAUTH_DIGEST) {
auth="Digest"; auth = "Digest";
result = Curl_output_digest(conn, result = Curl_output_digest(conn,
proxy, proxy,
(const unsigned char *)request, (const unsigned char *)request,
@ -629,11 +627,12 @@ output_auth_headers(struct connectdata *conn,
!Curl_checkProxyheaders(conn, "Proxy-authorization:")) || !Curl_checkProxyheaders(conn, "Proxy-authorization:")) ||
(!proxy && conn->bits.user_passwd && (!proxy && conn->bits.user_passwd &&
!Curl_checkheaders(conn, "Authorization:"))) { !Curl_checkheaders(conn, "Authorization:"))) {
auth="Basic"; auth = "Basic";
result = http_output_basic(conn, proxy); result = http_output_basic(conn, proxy);
if(result) if(result)
return result; return result;
} }
/* NOTE: this function should set 'done' TRUE, as the other auth /* NOTE: this function should set 'done' TRUE, as the other auth
functions work that way */ functions work that way */
authstatus->done = TRUE; authstatus->done = TRUE;
@ -641,9 +640,9 @@ output_auth_headers(struct connectdata *conn,
if(auth) { if(auth) {
infof(data, "%s auth using %s with user '%s'\n", infof(data, "%s auth using %s with user '%s'\n",
proxy?"Proxy":"Server", auth, proxy ? "Proxy" : "Server", auth,
proxy?(conn->proxyuser?conn->proxyuser:""): proxy ? (conn->proxyuser ? conn->proxyuser : "") :
(conn->user?conn->user:"")); (conn->user ? conn->user : ""));
authstatus->multi = (!authstatus->done) ? TRUE : FALSE; authstatus->multi = (!authstatus->done) ? TRUE : FALSE;
} }
else else
@ -735,7 +734,6 @@ Curl_http_output_auth(struct connectdata *conn,
return result; return result;
} }
/* /*
* Curl_http_input_auth() deals with Proxy-Authenticate: and WWW-Authenticate: * Curl_http_input_auth() deals with Proxy-Authenticate: and WWW-Authenticate:
* headers. They are dealt with both in the transfer.c main loop and in the * headers. They are dealt with both in the transfer.c main loop and in the
@ -780,7 +778,6 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
* request is sent, and then it is again set _after_ all response 401/407 * request is sent, and then it is again set _after_ all response 401/407
* headers have been received but then only to a single preferred method * headers have been received but then only to a single preferred method
* (bit). * (bit).
*
*/ */
while(*auth) { while(*auth) {
@ -893,6 +890,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
while(*auth && ISSPACE(*auth)) while(*auth && ISSPACE(*auth))
auth++; auth++;
} }
return CURLE_OK; return CURLE_OK;
} }
@ -934,8 +932,7 @@ static int http_should_fail(struct connectdata *conn)
** Any code >= 400 that's not 401 or 407 is always ** Any code >= 400 that's not 401 or 407 is always
** a terminal error ** a terminal error
*/ */
if((httpcode != 401) && if((httpcode != 401) && (httpcode != 407))
(httpcode != 407))
return 1; return 1;
/* /*
@ -986,7 +983,7 @@ static size_t readmoredata(char *buffer,
struct HTTP *http = conn->data->req.protop; struct HTTP *http = conn->data->req.protop;
size_t fullsize = size * nitems; size_t fullsize = size * nitems;
if(0 == http->postsize) if(!http->postsize)
/* nothing to return */ /* nothing to return */
return 0; return 0;
@ -1092,7 +1089,6 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
return result; return result;
} }
if((conn->handler->flags & PROTOPT_SSL) && conn->httpversion != 20) { if((conn->handler->flags & PROTOPT_SSL) && conn->httpversion != 20) {
/* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk /* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk
when we speak HTTPS, as if only a fraction of it is sent now, this data when we speak HTTPS, as if only a fraction of it is sent now, this data
@ -1100,7 +1096,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
buffer is using this size. buffer is using this size.
*/ */
sendsize= (size > CURL_MAX_WRITE_SIZE)?CURL_MAX_WRITE_SIZE:size; sendsize = (size > CURL_MAX_WRITE_SIZE) ? CURL_MAX_WRITE_SIZE : size;
/* OpenSSL is very picky and we must send the SAME buffer pointer to the /* OpenSSL is very picky and we must send the SAME buffer pointer to the
library when we attempt to re-send this buffer. Sending the same data library when we attempt to re-send this buffer. Sending the same data
@ -1123,7 +1119,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
* only send away a part). * only send away a part).
*/ */
/* how much of the header that was sent */ /* how much of the header that was sent */
size_t headlen = (size_t)amount>headersize?headersize:(size_t)amount; size_t headlen = (size_t)amount>headersize ? headersize : (size_t)amount;
size_t bodylen = amount - headlen; size_t bodylen = amount - headlen;
if(conn->data->set.verbose) { if(conn->data->set.verbose) {
@ -1242,11 +1238,11 @@ CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
buffer size that doubles the required size. If this new size buffer size that doubles the required size. If this new size
would wrap size_t, then just use the largest possible one */ would wrap size_t, then just use the largest possible one */
if((size > (size_t)-1/2) || (in->size_used > (size_t)-1/2) || if((size > (size_t)-1 / 2) || (in->size_used > (size_t)-1 / 2) ||
(~(size*2) < (in->size_used*2))) (~(size * 2) < (in->size_used * 2)))
new_size = (size_t)-1; new_size = (size_t)-1;
else else
new_size = (in->size_used+size)*2; new_size = (in->size_used+size) * 2;
if(in->buffer) if(in->buffer)
/* we have a buffer, enlarge the existing one */ /* we have a buffer, enlarge the existing one */
@ -1419,6 +1415,7 @@ static int https_getsock(struct connectdata *conn,
return GETSOCK_READSOCK(0); return GETSOCK_READSOCK(0);
} }
} }
return CURLE_OK; return CURLE_OK;
} }
#else #else
@ -1467,7 +1464,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
conn->seek_func = data->set.seek_func; /* restore */ conn->seek_func = data->set.seek_func; /* restore */
conn->seek_client = data->set.seek_client; /* restore */ conn->seek_client = data->set.seek_client; /* restore */
if(http == NULL) if(!http)
return CURLE_OK; return CURLE_OK;
if(http->send_buffer) { if(http->send_buffer) {
@ -1530,7 +1527,6 @@ CURLcode Curl_http_done(struct connectdata *conn,
return CURLE_OK; return CURLE_OK;
} }
/* /*
* Determine if we should use HTTP 1.1 (OR BETTER) for this request. Reasons * Determine if we should use HTTP 1.1 (OR BETTER) for this request. Reasons
* to avoid it include: * to avoid it include:
@ -1578,6 +1574,7 @@ static CURLcode expect100(struct SessionHandle *data,
data->state.expect100header = TRUE; data->state.expect100header = TRUE;
} }
} }
return result; return result;
} }
@ -1696,6 +1693,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
headers = headers->next; headers = headers->next;
} }
} }
return CURLE_OK; return CURLE_OK;
} }