diff options
Diffstat (limited to 'contrib/serf/ssltunnel.c')
-rw-r--r-- | contrib/serf/ssltunnel.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/contrib/serf/ssltunnel.c b/contrib/serf/ssltunnel.c index 480c799..28ca127 100644 --- a/contrib/serf/ssltunnel.c +++ b/contrib/serf/ssltunnel.c @@ -68,9 +68,10 @@ static apr_status_t handle_response(serf_request_t *request, apr_status_t status; serf_status_line sl; req_ctx_t *ctx = handler_baton; + serf_connection_t *conn = request->conn; if (! response) { - serf_connection_request_create(request->conn, + serf_connection_request_create(conn, setup_request, ctx); return APR_SUCCESS; @@ -97,17 +98,34 @@ static apr_status_t handle_response(serf_request_t *request, connection. */ if (sl.code >= 200 && sl.code < 300) { - request->conn->state = SERF_CONN_CONNECTED; + serf_bucket_t *hdrs; + const char *val; + + conn->state = SERF_CONN_CONNECTED; /* Body is supposed to be empty. */ apr_pool_destroy(ctx->pool); - serf_bucket_destroy(request->conn->ssltunnel_ostream); - request->conn->stream = NULL; + serf_bucket_destroy(conn->ssltunnel_ostream); + serf_bucket_destroy(conn->stream); + conn->stream = NULL; ctx = NULL; - serf__log(CONN_VERBOSE, __FILE__, - "successfully set up ssl tunnel on connection 0x%x\n", - request->conn); + serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt, + "successfully set up ssl tunnel.\n"); + + /* Fix for issue #123: ignore the "Connection: close" header here, + leaving the header in place would make the serf's main context + loop close this connection immediately after reading the 200 OK + response. */ + + hdrs = serf_bucket_response_get_headers(response); + val = serf_bucket_headers_get(hdrs, "Connection"); + if (val && strcasecmp("close", val) == 0) { + serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt, + "Ignore Connection: close header on this reponse, don't " + "close the connection now that the tunnel is set up.\n"); + serf__bucket_headers_remove(hdrs, "Connection"); + } return APR_EOF; } @@ -171,8 +189,8 @@ apr_status_t serf__ssltunnel_connect(serf_connection_t *conn) ctx); conn->state = SERF_CONN_SETUP_SSLTUNNEL; - serf__log(CONN_VERBOSE, __FILE__, - "setting up ssl tunnel on connection 0x%x\n", conn); + serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt, + "setting up ssl tunnel on connection.\n"); return APR_SUCCESS; } |