Example #1
0
static 	struct http_server_response *
http_server_request_create_fail_response(struct http_server_request *req,
	unsigned int status, const char *reason)
{
	struct http_server_response *resp;

	req->failed = TRUE;

	resp = http_server_response_create(req, status, reason);
	http_server_response_add_header
		(resp, "Content-Type", "text/plain; charset=utf-8");
	reason = t_strconcat(reason, "\r\n", NULL);
	http_server_response_set_payload_data
		(resp, (const unsigned char *)reason, strlen(reason));

	return resp;
}
Example #2
0
	
	http_server_connection_trigger_responses(conn);
}

static struct http_server_response *
http_server_request_create_fail_response(struct http_server_request *req,
	unsigned int status, const char *reason, const char *text)
	ATTR_NULL(4)
{
	struct http_server_response *resp;

	req->failed = TRUE;

	i_assert(status / 100 != 1 && status != 204 && status != 304);

	resp = http_server_response_create(req, status, reason);
	if (!http_request_method_is(&req->req, "HEAD")) {
		http_server_response_add_header
			(resp, "Content-Type", "text/plain; charset=utf-8");
		if (text == NULL)
			text = reason;
		text = t_strconcat(text, "\r\n", NULL);
		http_server_response_set_payload_data
			(resp, (const unsigned char *)text, strlen(text));
	}

	return resp;
}

static void
http_server_request_fail_full(struct http_server_request *req,