http-server-response.c revision ee2633056e67353157bfbce4d9e0d1c3ceaa627a
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainen/* Copyright (c) 2013-2016 Dovecot authors, see the included COPYING file */
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainenstatic inline void
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainenhttp_server_response_debug(struct http_server_response *resp,
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenstatic inline void
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenhttp_server_response_debug(struct http_server_response *resp,
597dba3488c648ffb375ee4a552bd52ac4346979Timo Sirainen const char *format, ...)
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen i_debug("http-server: request %s; %u response: %s",
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen http_server_request_label(resp->request), resp->status,
9511a40d933181045343110c8101b75887062aaeTimo Sirainenhttp_server_response_create(struct http_server_request *req,
42aaebd4b237403aff6bbfafdcdf52cf5f8c1c06Timo Sirainen resp = req->response = p_new(req->pool, struct http_server_response, 1);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenvoid http_server_response_free(struct http_server_response *resp)
9b1d6da0f2b42b8b6f612a570a83355c2a5088eeTimo Sirainenvoid http_server_response_add_header(struct http_server_response *resp,
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen i_assert(strchr(key, '\r') == NULL && strchr(key, '\n') == NULL);
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen i_assert(strchr(value, '\r') == NULL && strchr(value, '\n') == NULL);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen /* mark presence of special headers */
34ce7c45264902e217bfb5fa7f7a0aace9302074Timo Sirainen switch (key[0]) {
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen else if (strcasecmp(key, "Content-Length") == 0)
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen if (strcasecmp(key, "Transfer-Encoding") == 0)
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen str_printfa(resp->headers, "%s: %s\r\n", key, value);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainenvoid http_server_response_update_status(struct http_server_response *resp,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen unsigned int status,
10c96a244935de4add8213ba0b894178dfb889a5Timo Sirainen /* free not called because pool is alloconly */
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen resp->reason = p_strdup(resp->request->pool, reason);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenvoid http_server_response_set_date(struct http_server_response *resp,
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainenvoid http_server_response_set_payload(struct http_server_response *resp,
9511a40d933181045343110c8101b75887062aaeTimo Sirainen if ((ret = i_stream_get_size(input, TRUE, &resp->payload_size)) <= 0) {
unsigned char *payload_data;
if (size == 0)
bool close)
unsigned int iov_count, i;
if (ret > 0) {
if (i < iov_count) {
int ret;
ret = 0;
return ret;
const char **error_r)
const char **error_r)
int ret = 0;
if (ret >= 0) {
return ret;
const char **error_r)
int ret;
T_BEGIN {
if (ret < 0)
} T_END;
return ret;