http-server-response.c revision 564e117d86ce5b659f9b9570edddc566f9ebb5df
/* Copyright (c) 2013-2014 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "array.h"
#include "istream.h"
#include "ostream.h"
#include "http-date.h"
#include "http-transfer.h"
#include "http-server-private.h"
/*
* Logging
*/
static inline void
static inline void
const char *format, ...)
{
i_debug("http-server: request %s; %u response: %s",
}
}
/*
* Response
*/
struct http_server_response *
{
struct http_server_response *resp;
return resp;
}
{
}
{
/* mark presence of special headers */
switch (key[0]) {
case 'c': case 'C':
break;
case 'd': case 'D':
break;
case 't': case 'T':
break;
}
}
{
}
{
int ret;
if (ret < 0) {
i_error("i_stream_get_size(%s) failed: %m",
}
resp->payload_size = 0;
}
}
{
unsigned char *payload_data;
if (size == 0)
return;
}
struct http_server_response *resp,
const struct http_auth_challenge *chlng)
{
struct http_auth_challenge *new;
}
{
struct http_auth_challenge chlng;
}
bool close)
{
}
{
}
{
}
{
}
static void
{
}
}
static void
{
(void)http_server_connection_output(conn);
}
const char **error_r)
{
/* chunked ostream needs to write to the parent stream's buffer */
ret = -1;
} else if (output->stream_errno != 0) {
}
ret = -1;
} else {
}
if (!resp->payload_chunked &&
return -1;
}
/* output is blocking */
//http_server_response_debug(resp, "Partially sent payload");
} else {
/* input is blocking */
}
return ret < 0 ? -1 : 0;
}
const char **error_r)
{
int ret = 0;
/* create status line */
/* create special headers implicitly if not set explicitly using
http_server_response_add_header() */
if (!resp->have_hdr_date) {
}
}
if (resp->payload_chunked) {
/* cannot use Transfer-Encoding */
/* connection close marks end of payload */
} else {
if (!resp->have_hdr_body_spec)
}
/* send Content-Length if we have specified a payload,
even if it's 0 bytes. */
if (!resp->have_hdr_body_spec) {
resp->payload_size);
}
/* RFC 7230, Section 3.3: Message Body
Responses to the HEAD request method (Section 4.3.2 of [RFC7231])
never include a message body because the associated response header
fields (e.g., Transfer-Encoding, Content-Length, etc.), if present,
indicate only what their values would have been if the request method
had been GET (Section 4.3.1 of [RFC7231]). 2xx (Successful) responses
to a CONNECT request method (Section 4.3.6 of [RFC7231]) switch to
tunnel mode instead of having a message body. All 1xx (Informational),
204 (No Content), and 304 (Not Modified) responses do not include a
message body. All other responses do include a message body, although
the body might be of zero length.
RFC 7230, Section 3.3.2: Content-Length
A server MUST NOT send a Content-Length header field in any 2xx
(Successful) response to a CONNECT request (Section 4.3.6 of [RFC7231]).
-> Create empty body if it is missing.
*/
if (!resp->have_hdr_body_spec)
}
if (!resp->have_hdr_connection) {
}
/* status line + implicit headers */
/* explicit headers */
/* end of header */
}
ret = -1;
}
ret = -1;
} else {
}
return ret;
}
const char **error_r)
{
int ret;
T_BEGIN {
} T_END;
return ret;
}