FreeBSD/contrib/serf/ssltunnel.c
/* If a 200 OK was received for the CONNECT request, consider the connection
   as ready for use. */
If a 200 OK was received for the CONNECT request, consider the connection
as ready for use.
If a 200 OK was received for the CONNECT request consider the connection as ready for use .
static apr_status_t handle_response(serf_request_t *request,
                                    serf_bucket_t *response,
                                    void *handler_baton,
                                    apr_pool_t *pool)
{
    apr_status_t status;
    serf_status_line sl;
    req_ctx_t *ctx = handler_baton;
    serf_connection_t *conn = request->conn;
    if (!response)
        return APR_SUCCESS;
    status = serf_bucket_response_status(response, &sl);
    if (SERF_BUCKET_READ_ERROR(status)) {
        return status;
    }
    if (!sl.version && (APR_STATUS_IS_EOF(status) ||
                      APR_STATUS_IS_EAGAIN(status)))
    {
        return status;
    }
    status = serf_bucket_response_wait_for_headers(response);
    if (status && !APR_STATUS_IS_EOF(status)) {
        return status;
    }
    if (sl.code >= 200 && sl.code < 300) {
        serf_bucket_t *hdrs;
        const char *val;
        conn->state = SERF_CONN_CONNECTED;
        apr_pool_destroy(ctx->pool);
        serf_bucket_destroy(conn->ssltunnel_ostream);
        serf_bucket_destroy(conn->stream);
        conn->stream = NULL;
        ctx = NULL;
        serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt,
                      "successfully set up ssl tunnel.\n");
        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;
    }
    return SERF_ERROR_SSLTUNNEL_SETUP_FAILED;
}
static apr_status_t handle_response ( serf_request_t * request , serf_bucket_t * response , void * handler_baton , apr_pool_t * pool ) { apr_status_t status ; serf_status_line sl ; req_ctx_t * ctx = handler_baton ; serf_connection_t * conn = request -> conn ; if ( ! response ) return APR_SUCCESS ; status = serf_bucket_response_status ( response , & sl ) ; if ( SERF_BUCKET_READ_ERROR ( status ) ) { return status ; } if ( ! sl . version && ( APR_STATUS_IS_EOF ( status ) || APR_STATUS_IS_EAGAIN ( status ) ) ) { return status ; } status = serf_bucket_response_wait_for_headers ( response ) ; if ( status && ! APR_STATUS_IS_EOF ( status ) ) { return status ; } if ( sl . code >= 200 && sl . code < 300 ) { serf_bucket_t * hdrs ; const char * val ; conn -> state = SERF_CONN_CONNECTED ; apr_pool_destroy ( ctx -> pool ) ; serf_bucket_destroy ( conn -> ssltunnel_ostream ) ; serf_bucket_destroy ( conn -> stream ) ; conn -> stream = NULL ; ctx = NULL ; serf__log_skt ( CONN_VERBOSE , __FILE__ , conn -> skt , " \n " ) ; hdrs = serf_bucket_response_get_headers ( response ) ; val = serf_bucket_headers_get ( hdrs , " " ) ; if ( val && strcasecmp ( " " , val ) == 0 ) { serf__log_skt ( CONN_VERBOSE , __FILE__ , conn -> skt , " " " \n " ) ; serf__bucket_headers_remove ( hdrs , " " ) ; } return APR_EOF ; } return SERF_ERROR_SSLTUNNEL_SETUP_FAILED ; }
If a 200 OK was received for the CONNECT request, consider the connection
as ready for use.
If a 200 OK was received for the CONNECT request consider the connection as ready for use .
/* CONNECT request was cancelled. Assuming that this is during connection
       reset, we can safely discard the request as a new one will be created
       when setting up the next connection. */ /* RFC 2817:  Any successful (2xx) response to a CONNECT request indicates
       that the proxy has established a connection to the requested host and
       port, and has switched to tunneling the current connection to that server
       connection.
    */ /* Body is supposed to be empty. */ /* 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. */ /* Authentication failure and 2xx Ok are handled at this point,
       the rest are errors. */