Commit d5affe57 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Having wasted half an hour on it (again) it's time to kill the

"response/reason" confusion for good.
parent 22b84885
......@@ -984,7 +984,7 @@ void VGZ_WrwFlush(struct req *, struct vgz *vg);
unsigned HTTP_estimate(unsigned nhttp);
void HTTP_Copy(struct http *to, const struct http * const fm);
struct http *HTTP_create(void *p, uint16_t nhttp);
const char *http_StatusMessage(unsigned);
const char *http_Status2Reason(unsigned);
unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd);
void HTTP_Init(void);
void http_PutResponse(struct http *to, const char *proto, uint16_t status,
......
......@@ -116,7 +116,7 @@ static struct http_msg {
};
const char *
http_StatusMessage(unsigned status)
http_Status2Reason(unsigned status)
{
struct http_msg *mp;
......@@ -568,7 +568,7 @@ http_ForceGet(const struct http *to)
void
http_PutResponse(struct http *to, const char *proto, uint16_t status,
const char *response)
const char *reason)
{
char buf[4];
......@@ -583,9 +583,9 @@ http_PutResponse(struct http *to, const char *proto, uint16_t status,
to->status = status;
bprintf(buf, "%03d", status % 1000);
http_PutField(to, HTTP_HDR_STATUS, buf);
if (response == NULL)
response = http_StatusMessage(status);
http_SetH(to, HTTP_HDR_RESPONSE, response);
if (reason == NULL)
reason = http_Status2Reason(status);
http_SetH(to, HTTP_HDR_REASON, reason);
}
/*--------------------------------------------------------------------
......@@ -689,7 +689,7 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how)
http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1");
to->status = fm->status;
http_linkh(to, fm, HTTP_HDR_STATUS);
http_linkh(to, fm, HTTP_HDR_RESPONSE);
http_linkh(to, fm, HTTP_HDR_REASON);
http_filterfields(to, fm, how);
}
......@@ -708,7 +708,7 @@ http_Merge(const struct http *fm, struct http *to, int not_ce)
to->status = fm->status;
http_SetH(to, HTTP_HDR_PROTO, fm->hd[HTTP_HDR_PROTO].b);
http_SetH(to, HTTP_HDR_STATUS, fm->hd[HTTP_HDR_STATUS].b);
http_SetH(to, HTTP_HDR_RESPONSE, fm->hd[HTTP_HDR_RESPONSE].b);
http_SetH(to, HTTP_HDR_REASON, fm->hd[HTTP_HDR_REASON].b);
for (u = HTTP_HDR_FIRST; u < fm->nhd; u++)
fm->hdf[u] |= HDF_MARKER;
......
......@@ -310,7 +310,7 @@ htc_splitline(struct http *hp, const struct http_conn *htc, int req)
} else {
h1 = HTTP_HDR_PROTO;
h2 = HTTP_HDR_STATUS;
h3 = HTTP_HDR_RESPONSE;
h3 = HTTP_HDR_REASON;
}
/* Skip leading LWS */
......@@ -493,13 +493,13 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc)
} else
htc_proto_ver(hp);
if (hp->hd[HTTP_HDR_RESPONSE].b == NULL ||
!Tlen(hp->hd[HTTP_HDR_RESPONSE])) {
if (hp->hd[HTTP_HDR_REASON].b == NULL ||
!Tlen(hp->hd[HTTP_HDR_REASON])) {
/* Backend didn't send a response string, use the standard */
hp->hd[HTTP_HDR_RESPONSE].b =
TRUST_ME(http_StatusMessage(hp->status));
hp->hd[HTTP_HDR_RESPONSE].e =
strchr(hp->hd[HTTP_HDR_RESPONSE].b, '\0');
hp->hd[HTTP_HDR_REASON].b =
TRUST_ME(http_Status2Reason(hp->status));
hp->hd[HTTP_HDR_REASON].e =
strchr(hp->hd[HTTP_HDR_REASON].b, '\0');
}
return (retval);
}
......@@ -523,7 +523,7 @@ HTTP1_Write(const struct worker *w, const struct http *hp, int resp)
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_REASON], "\r\n");
} else {
AN(hp->hd[HTTP_HDR_URL].b);
l = WRW_WriteH(w, &hp->hd[HTTP_HDR_METHOD], " ");
......
......@@ -63,7 +63,7 @@ VRT_error(const struct vrt_ctx *ctx, unsigned code, const char *reason)
code = 503;
ctx->req->err_code = (uint16_t)code;
ctx->req->err_reason =
reason ? reason : http_StatusMessage(ctx->req->err_code);
reason ? reason : http_Status2Reason(ctx->req->err_code);
}
/*--------------------------------------------------------------------*/
......
......@@ -122,11 +122,11 @@ VRT_HDR_LR(req, url, HTTP_HDR_URL)
VRT_HDR_LR(req, proto, HTTP_HDR_PROTO)
VRT_HDR_R(obj, proto, HTTP_HDR_PROTO)
VRT_HDR_R(obj, reason, HTTP_HDR_RESPONSE)
VRT_HDR_R(obj, reason, HTTP_HDR_REASON)
VRT_STATUS_R(obj)
VRT_HDR_LR(resp, proto, HTTP_HDR_PROTO)
VRT_HDR_LR(resp, reason, HTTP_HDR_RESPONSE)
VRT_HDR_LR(resp, reason, HTTP_HDR_REASON)
VRT_STATUS_L(resp)
VRT_STATUS_R(resp)
......@@ -134,7 +134,7 @@ VRT_HDR_LR(bereq, method, HTTP_HDR_METHOD)
VRT_HDR_LR(bereq, url, HTTP_HDR_URL)
VRT_HDR_LR(bereq, proto, HTTP_HDR_PROTO)
VRT_HDR_LR(beresp, proto, HTTP_HDR_PROTO)
VRT_HDR_LR(beresp, reason, HTTP_HDR_RESPONSE)
VRT_HDR_LR(beresp, reason, HTTP_HDR_REASON)
VRT_STATUS_L(beresp)
VRT_STATUS_R(beresp)
......
......@@ -55,7 +55,7 @@ SLTH(Protocol, HTTP_HDR_PROTO, 1, 1, "protocol",
SLTH(Status, HTTP_HDR_STATUS, 0, 1, "status",
"The HTTP status code received.\n\n"
)
SLTH(Response, HTTP_HDR_RESPONSE, 0, 1, "response",
SLTH(Reason, HTTP_HDR_REASON, 0, 1, "response",
"The HTTP response string received.\n\n"
)
SLTH(Header, HTTP_HDR_FIRST, 1, 1, "header",
......
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