size_t default_max_headers_size;
ev_uint64_t default_max_body_size;
+ const char *default_content_type;
/* Bitmask of all HTTP methods that we accept and pass to user
* callbacks. */
/* Potentially add headers for unidentified content. */
if (evhttp_response_needs_body(req)) {
if (evhttp_find_header(req->output_headers,
- "Content-Type") == NULL) {
+ "Content-Type") == NULL
+ && evcon->http_server->default_content_type) {
evhttp_add_header(req->output_headers,
- "Content-Type", "text/html; charset=ISO-8859-1");
+ "Content-Type",
+ evcon->http_server->default_content_type);
}
}
evutil_timerclear(&http->timeout);
evhttp_set_max_headers_size(http, EV_SIZE_MAX);
evhttp_set_max_body_size(http, EV_SIZE_MAX);
+ evhttp_set_default_content_type(http, "text/html; charset=ISO-8859-1");
evhttp_set_allowed_methods(http,
EVHTTP_REQ_GET |
EVHTTP_REQ_POST |
http->default_max_body_size = max_body_size;
}
+void
+evhttp_set_default_content_type(struct evhttp *http,
+ const char *content_type) {
+ http->default_content_type = content_type;
+}
+
void
evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods)
{
/** XXX Document. */
void evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size);
+/**
+ Set the value to use for the Content-Type header when none was provided. If
+ the content type string is NULL, the Content-Type header will not be
+ automatically added.
+
+ @param http the http server on which to set the default content type
+ @param content_type the value for the Content-Type header
+*/
+void evhttp_set_default_content_type(struct evhttp *http,
+ const char *content_type);
+
/**
Sets the what HTTP methods are supported in requests accepted by this
server, and passed to user callbacks.