http-server-request.c revision 2974dca6be5120e49279f06c8aa952e5fac56048
/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "ostream.h"
#include "istream-private.h"
#include "http-server-private.h"
/*
* Logging
*/
static inline void
static inline void
const char *format, ...)
{
i_debug("http-server: request %s: %s",
}
}
static inline void
static inline void
const char *format, ...)
{
i_error("http-server: request %s: %s",
}
static inline void
static inline void
const char *format, ...)
{
i_info("http-server: request %s: %s",
}
/*
* Request
*/
struct http_server_request *
{
static unsigned int id_counter = 0;
struct http_server_request *req;
return req;
}
{
}
{
return TRUE;
}
}
return FALSE;
}
bool close)
{
}
{
/* just make sure the request ends in a proper state */
if (req->delay_destroy) {
}
}
void (*callback)(void *),
void *context)
{
}
const char *reason)
{
return;
/* send best-effort response if appropriate */
if (!conn->output_locked &&
static const char *response =
"HTTP/1.1 500 Internal Server Error\r\n"
"Content-Length: 0\r\n"
"\r\n";
}
/* close the connection */
}
}
}
}
}
const struct http_request *
{
}
{
}
struct http_server_response *
{
}
struct http_auth_credentials *credentials)
{
const char *auth;
return 0;
return -1;
return 1;
}
{
}
{
}
{
}
{
}
{
}
{
if (!http_server_request_is_complete(req)) {
break;
}
break;
break;
break;
default:
i_unreached();
}
}
{
if (tunnel_callback == NULL) {
if (req->connection_close) {
t_strdup_printf("Server closed connection: %u %s",
return;
"Connection input is broken");
return;
"Client requested connection close");
return;
}
}
if (tunnel_callback != NULL) {
return;
}
}
static struct http_server_response *
ATTR_NULL(4)
{
struct http_server_response *resp;
}
return resp;
}
static void
ATTR_NULL(4)
{
struct http_server_response *resp;
}
{
}
{
}
{
}
{
struct http_server_response *resp;
reason = "Unauthenticated";
}
{
struct http_auth_challenge chlng;
}
/*
* Payload input stream
*/
struct http_server_istream {
struct istream_private istream;
struct http_server_request *req;
};
static void
{
struct http_server_istream *hsristream =
(struct http_server_istream *)stream;
return;
}
static void
{
}
}
static ssize_t
{
struct http_server_istream *hsristream =
(struct http_server_istream *)stream;
struct http_server *server;
struct http_server_connection *conn;
/* request already gone (we shouldn't get here) */
return -1;
}
hsristream->read_status = 0;
hsristream->read_status == 0) {
}
if (!http_server_request_unref(&req))
}
return ret;
}
static void
{
struct http_server_istream *hsristream =
(struct http_server_istream *)stream;
/* get to same position in parent stream */
}
}
struct istream *
bool blocking)
{
struct http_server_istream *hsristream;
return req->payload_input;
}
/*
* Payload handling
*/
static void
struct http_server_payload_handler *handler ,
struct http_server_request *req)
{
}
struct http_server_payload_handler **_handler)
{
if (handler->in_callback) {
/* don't destroy handler while in callback */
return;
}
}
struct http_server_payload_handler *handler)
{
}
/* pump-based */
struct http_server_payload_handler_pump {
struct http_server_payload_handler handler;
struct iostream_pump *pump;
void (*callback)(void *);
void *context;
};
static void
struct http_server_payload_handler *handler)
{
struct http_server_payload_handler_pump *phandler =
(struct http_server_payload_handler_pump *)handler;
}
static void
struct http_server_payload_handler *handler)
{
struct http_server_payload_handler_pump *phandler =
(struct http_server_payload_handler_pump *)handler;
}
static void
struct http_server_payload_handler_pump *phandler)
{
switch (status) {
413, "Payload Too Large");
} else {
}
break;
"iostream_pump: read(%s) failed: %s",
400, "Bad Request");
break;
if (output->stream_errno != 0) {
"iostream_pump: write(%s) failed: %s",
}
500, "Internal Server Error");
break;
}
}
{
struct http_server_payload_handler_pump *phandler;
int ret;
} else {
if (ret < 0) {
"i_stream_get_size(%s) failed: %s",
500, "Internal Server Error");
return;
}
if (payload_size > max_size) {
413, "Payload Too Large");
return;
}
}
}
}
{
}
/* raw */
struct http_server_payload_handler_raw {
struct http_server_payload_handler handler;
void *context;
};
static void
struct http_server_payload_handler *handler)
{
struct http_server_payload_handler_raw *rhandler =
(struct http_server_payload_handler_raw *)handler;
}
static void
struct http_server_payload_handler *handler)
{
struct http_server_payload_handler_raw *rhandler =
(struct http_server_payload_handler_raw *)handler;
}
static void
struct http_server_payload_handler_raw *rhandler)
{
"read(%s) failed: %s",
400, "Bad Request");
}
} else {
return;
}
}
{
struct http_server_payload_handler_raw *rhandler;
}