Commit 4339ecb8 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

The HTTP/2 draft -13 seems pretty final with respect to the Connection:

header being a HTTP/1.x thing only.

Move the handling accordingly
parent e0e89a69
......@@ -946,9 +946,10 @@ void http_SetStatus(struct http *to, uint16_t status);
const char *http_GetReq(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
int http_IsHdr(const txt *hh, const char *hdr);
enum sess_close http_DoConnection(const struct http *);
void http_CopyHome(const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen,
uint8_t flag);
void http_CollectHdr(struct http *hp, const char *hdr);
void http_VSL_log(const struct http *hp);
void http_Merge(const struct http *fm, struct http *to, int not_ce);
......@@ -971,6 +972,7 @@ ssize_t HTTP1_Read(struct http_conn *htc, void *d, size_t len);
enum htc_status_e HTTP1_Complete(struct http_conn *htc);
uint16_t HTTP1_DissectRequest(struct req *);
uint16_t HTTP1_DissectResponse(struct http *sp, const struct http_conn *htc);
enum sess_close HTTP1_DoConnection(const struct http *);
unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*);
#define HTTPH(a, b, c) extern char b[];
......
......@@ -263,6 +263,23 @@ http_findhdr(const struct http *hp, unsigned l, const char *hdr)
return (0);
}
/*--------------------------------------------------------------------
*/
void
http_MarkHeader(const struct http *hp, const char *hdr, unsigned hdrlen,
uint8_t flag)
{
unsigned u;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
u = http_findhdr(hp, hdrlen, hdr);
if (u == 0)
return;
hp->hdf[u] |= flag;
}
/*--------------------------------------------------------------------
* This function collapses multiple headerlines of the same name.
* The lines are joined with a comma, according to [rfc2616, 4.2bot, p32]
......@@ -489,45 +506,6 @@ http_GetHdrField(const struct http *hp, const char *hdr,
return (i);
}
/*--------------------------------------------------------------------
* XXX: redo with http_GetHdrField() ?
*/
enum sess_close
http_DoConnection(const struct http *hp)
{
char *p, *q;
enum sess_close ret;
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
if (hp->protover < 11)
return (SC_REQ_HTTP10);
return (SC_NULL);
}
ret = SC_NULL;
AN(p);
for (; *p; p++) {
if (vct_issp(*p))
continue;
if (*p == ',')
continue;
for (q = p + 1; *q; q++)
if (*q == ',' || vct_issp(*q))
break;
u = pdiff(p, q);
if (u == 5 && !strncasecmp(p, "close", u))
ret = SC_REQ_CLOSE;
u = http_findhdr(hp, u, p);
if (u != 0)
hp->hdf[u] |= HDF_FILTER;
if (!*q)
break;
p = q;
}
return (ret);
}
/*--------------------------------------------------------------------*/
int
......
......@@ -380,7 +380,7 @@ http1_dissect(struct worker *wrk, struct req *req)
AZ(req->err_code);
req->ws_req = WS_Snapshot(req->ws);
req->doclose = http_DoConnection(req->http);
req->doclose = HTTP1_DoConnection(req->http);
http_Unset(req->http, H_Expect);
......
......@@ -411,8 +411,6 @@ htc_proto_ver(struct http *hp)
/*--------------------------------------------------------------------*/
#include <stdio.h>
uint16_t
HTTP1_DissectRequest(struct req *req)
{
......@@ -506,6 +504,42 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc)
return (retval);
}
/*--------------------------------------------------------------------
*/
enum sess_close
HTTP1_DoConnection(const struct http *hp)
{
char *p, *q;
enum sess_close ret;
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
if (hp->protover < 11)
return (SC_REQ_HTTP10);
return (SC_NULL);
}
ret = SC_NULL;
AN(p);
for (; *p; p++) {
if (vct_issp(*p))
continue;
if (*p == ',')
continue;
for (q = p + 1; *q; q++)
if (*q == ',' || vct_issp(*q))
break;
u = pdiff(p, q);
if (u == 5 && !strncasecmp(p, "close", u))
ret = SC_REQ_CLOSE;
http_MarkHeader(hp, p, u, HDF_FILTER);
if (!*q)
break;
p = q;
}
return (ret);
}
/*--------------------------------------------------------------------*/
unsigned
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment