Deleted Added
full compact
ssltunnel.c (253895) ssltunnel.c (262324)
1/* Copyright 2011 Justin Erenkrantz and Greg Stein
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *

--- 54 unchanged lines hidden (view full) ---

63static apr_status_t handle_response(serf_request_t *request,
64 serf_bucket_t *response,
65 void *handler_baton,
66 apr_pool_t *pool)
67{
68 apr_status_t status;
69 serf_status_line sl;
70 req_ctx_t *ctx = handler_baton;
1/* Copyright 2011 Justin Erenkrantz and Greg Stein
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *

--- 54 unchanged lines hidden (view full) ---

63static apr_status_t handle_response(serf_request_t *request,
64 serf_bucket_t *response,
65 void *handler_baton,
66 apr_pool_t *pool)
67{
68 apr_status_t status;
69 serf_status_line sl;
70 req_ctx_t *ctx = handler_baton;
71 serf_connection_t *conn = request->conn;
71
72 if (! response) {
72
73 if (! response) {
73 serf_connection_request_create(request->conn,
74 serf_connection_request_create(conn,
74 setup_request,
75 ctx);
76 return APR_SUCCESS;
77 }
78
79 status = serf_bucket_response_status(response, &sl);
80 if (SERF_BUCKET_READ_ERROR(status)) {
81 return status;

--- 10 unchanged lines hidden (view full) ---

92 }
93
94 /* RFC 2817: Any successful (2xx) response to a CONNECT request indicates
95 that the proxy has established a connection to the requested host and
96 port, and has switched to tunneling the current connection to that server
97 connection.
98 */
99 if (sl.code >= 200 && sl.code < 300) {
75 setup_request,
76 ctx);
77 return APR_SUCCESS;
78 }
79
80 status = serf_bucket_response_status(response, &sl);
81 if (SERF_BUCKET_READ_ERROR(status)) {
82 return status;

--- 10 unchanged lines hidden (view full) ---

93 }
94
95 /* RFC 2817: Any successful (2xx) response to a CONNECT request indicates
96 that the proxy has established a connection to the requested host and
97 port, and has switched to tunneling the current connection to that server
98 connection.
99 */
100 if (sl.code >= 200 && sl.code < 300) {
100 request->conn->state = SERF_CONN_CONNECTED;
101 serf_bucket_t *hdrs;
102 const char *val;
101
103
104 conn->state = SERF_CONN_CONNECTED;
105
102 /* Body is supposed to be empty. */
103 apr_pool_destroy(ctx->pool);
106 /* Body is supposed to be empty. */
107 apr_pool_destroy(ctx->pool);
104 serf_bucket_destroy(request->conn->ssltunnel_ostream);
105 request->conn->stream = NULL;
108 serf_bucket_destroy(conn->ssltunnel_ostream);
109 serf_bucket_destroy(conn->stream);
110 conn->stream = NULL;
106 ctx = NULL;
107
111 ctx = NULL;
112
108 serf__log(CONN_VERBOSE, __FILE__,
109 "successfully set up ssl tunnel on connection 0x%x\n",
110 request->conn);
113 serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt,
114 "successfully set up ssl tunnel.\n");
111
115
116 /* Fix for issue #123: ignore the "Connection: close" header here,
117 leaving the header in place would make the serf's main context
118 loop close this connection immediately after reading the 200 OK
119 response. */
120
121 hdrs = serf_bucket_response_get_headers(response);
122 val = serf_bucket_headers_get(hdrs, "Connection");
123 if (val && strcasecmp("close", val) == 0) {
124 serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt,
125 "Ignore Connection: close header on this reponse, don't "
126 "close the connection now that the tunnel is set up.\n");
127 serf__bucket_headers_remove(hdrs, "Connection");
128 }
129
112 return APR_EOF;
113 }
114
115 /* Authentication failure and 2xx Ok are handled at this point,
116 the rest are errors. */
117 return SERF_ERROR_SSLTUNNEL_SETUP_FAILED;
118}
119

--- 46 unchanged lines hidden (view full) ---

166 detect_eof,
167 conn);
168
169 serf__ssltunnel_request_create(conn,
170 setup_request,
171 ctx);
172
173 conn->state = SERF_CONN_SETUP_SSLTUNNEL;
130 return APR_EOF;
131 }
132
133 /* Authentication failure and 2xx Ok are handled at this point,
134 the rest are errors. */
135 return SERF_ERROR_SSLTUNNEL_SETUP_FAILED;
136}
137

--- 46 unchanged lines hidden (view full) ---

184 detect_eof,
185 conn);
186
187 serf__ssltunnel_request_create(conn,
188 setup_request,
189 ctx);
190
191 conn->state = SERF_CONN_SETUP_SSLTUNNEL;
174 serf__log(CONN_VERBOSE, __FILE__,
175 "setting up ssl tunnel on connection 0x%x\n", conn);
192 serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt,
193 "setting up ssl tunnel on connection.\n");
176
177 return APR_SUCCESS;
178}
194
195 return APR_SUCCESS;
196}