#define HTTP_OK 200
#define HTTP_MOVEPERM 301
#define HTTP_MOVETEMP 302
+#define HTTP_BADREQUEST 400
#define HTTP_NOTFOUND 404
#define HTTP_SERVUNAVAIL 503
void
evrpc_reqstate_free(struct evrpc_req_generic* rpc_state)
{
- struct evrpc *rpc = rpc_state->rpc;
-
/* clean up all memory */
if (rpc_state != NULL) {
+ struct evrpc *rpc = rpc_state->rpc;
+
if (rpc_state->request != NULL)
rpc->request_free(rpc_state);
if (rpc_state->reply != NULL)
struct evhttp_request* req = TAILQ_FIRST(&evcon->requests);
assert(req != NULL);
- /* reset the connection */
- evhttp_connection_reset(evcon);
-
if (req->cb != NULL) {
- /* xxx: maybe we need to pass the request here? */
+ /*
+ * we are passing the request object if we have an incoming
+ * request that somehow needs to be answered. we need to
+ * wait for the answer to travel over the wire before we can
+ * kill the connection.
+ */
+ if (evcon->flags & EVHTTP_CON_INCOMING) {
+ (*req->cb)(req, req->cb_arg);
+ return;
+ }
(*req->cb)(NULL, req->cb_arg);
}
+ /* reset the connection */
+ evhttp_connection_reset(evcon);
+
TAILQ_REMOVE(&evcon->requests, req, next);
evhttp_request_free(req);
struct evhttp *http = arg;
struct evhttp_cb *cb;
+ if (req->uri == NULL) {
+ evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
+ return;
+ }
+
/* Test for different URLs */
TAILQ_FOREACH(cb, &http->callbacks, next) {
int res;