Fossil SCM
Slight modularization when building the request to establish https tunnel over proxy.
Commit
491e6d30fc294810188027e011195a2911c13097
Parent
f3037e176370574…
1 file changed
+15
-18
+15
-18
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -174,31 +174,28 @@ | ||
| 174 | 174 | (void)BIO_reset(iBio); |
| 175 | 175 | BIO_free_all(iBio); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | +/* See RFC2817 for details */ | |
| 179 | 180 | static int establish_proxy_tunnel(BIO *bio){ |
| 180 | 181 | int rc, httpVerMin; |
| 181 | - char *connStr, *bbuf; | |
| 182 | - Blob reply; | |
| 182 | + char *bbuf; | |
| 183 | + Blob snd, reply; | |
| 183 | 184 | int done=0,end=0; |
| 184 | - if( !g.urlProxyAuth ){ | |
| 185 | - connStr = mprintf("CONNECT %s:%d HTTP/1.1\r\n" | |
| 186 | - "Host: %s\r\n" | |
| 187 | - "Proxy-Connection: keep-alive\r\n", | |
| 188 | - "User-Agent: Fossil/" RELEASE_VERSION "\r\n\r\n", | |
| 189 | - g.urlHostname, g.proxyOrigPort, g.urlHostname); | |
| 190 | - }else{ | |
| 191 | - connStr = mprintf("CONNECT %s:%d HTTP/1.1\r\n" | |
| 192 | - "Host: %s\r\n" | |
| 193 | - "Proxy-Connection: keep-alive\r\n" | |
| 194 | - "User-Agent: Fossil/" RELEASE_VERSION "\r\n" | |
| 195 | - "Proxy-Authorization: %s\r\n\r\n", | |
| 196 | - g.urlHostname, g.proxyOrigPort, g.urlHostname, g.urlProxyAuth); | |
| 197 | - } | |
| 198 | - BIO_write(bio, connStr, strlen(connStr)); | |
| 199 | - free(connStr); | |
| 185 | + blob_zero(&snd); | |
| 186 | + blob_appendf(&snd, "CONNECT %s:%d HTTP/1.1\r\n", g.urlHostname, | |
| 187 | + g.proxyOrigPort); | |
| 188 | + blob_appendf(&snd, "Host: %s:%d\r\n", g.urlHostname, g.proxyOrigPort); | |
| 189 | + if( g.urlProxyAuth ){ | |
| 190 | + blob_appendf(&snd, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); | |
| 191 | + } | |
| 192 | + blob_append(&snd, "Proxy-Connection: keep-alive\r\n", -1); | |
| 193 | + blob_append(&snd, "User-Agent: Fossil/" RELEASE_VERSION "\r\n", -1); | |
| 194 | + blob_append(&snd, "\r\n", 2); | |
| 195 | + BIO_write(bio, blob_buffer(&snd), blob_size(&snd)); | |
| 196 | + blob_reset(&snd); | |
| 200 | 197 | |
| 201 | 198 | /* Wait for end of reply */ |
| 202 | 199 | blob_zero(&reply); |
| 203 | 200 | do{ |
| 204 | 201 | int len; |
| 205 | 202 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -174,31 +174,28 @@ | |
| 174 | (void)BIO_reset(iBio); |
| 175 | BIO_free_all(iBio); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | static int establish_proxy_tunnel(BIO *bio){ |
| 180 | int rc, httpVerMin; |
| 181 | char *connStr, *bbuf; |
| 182 | Blob reply; |
| 183 | int done=0,end=0; |
| 184 | if( !g.urlProxyAuth ){ |
| 185 | connStr = mprintf("CONNECT %s:%d HTTP/1.1\r\n" |
| 186 | "Host: %s\r\n" |
| 187 | "Proxy-Connection: keep-alive\r\n", |
| 188 | "User-Agent: Fossil/" RELEASE_VERSION "\r\n\r\n", |
| 189 | g.urlHostname, g.proxyOrigPort, g.urlHostname); |
| 190 | }else{ |
| 191 | connStr = mprintf("CONNECT %s:%d HTTP/1.1\r\n" |
| 192 | "Host: %s\r\n" |
| 193 | "Proxy-Connection: keep-alive\r\n" |
| 194 | "User-Agent: Fossil/" RELEASE_VERSION "\r\n" |
| 195 | "Proxy-Authorization: %s\r\n\r\n", |
| 196 | g.urlHostname, g.proxyOrigPort, g.urlHostname, g.urlProxyAuth); |
| 197 | } |
| 198 | BIO_write(bio, connStr, strlen(connStr)); |
| 199 | free(connStr); |
| 200 | |
| 201 | /* Wait for end of reply */ |
| 202 | blob_zero(&reply); |
| 203 | do{ |
| 204 | int len; |
| 205 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -174,31 +174,28 @@ | |
| 174 | (void)BIO_reset(iBio); |
| 175 | BIO_free_all(iBio); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /* See RFC2817 for details */ |
| 180 | static int establish_proxy_tunnel(BIO *bio){ |
| 181 | int rc, httpVerMin; |
| 182 | char *bbuf; |
| 183 | Blob snd, reply; |
| 184 | int done=0,end=0; |
| 185 | blob_zero(&snd); |
| 186 | blob_appendf(&snd, "CONNECT %s:%d HTTP/1.1\r\n", g.urlHostname, |
| 187 | g.proxyOrigPort); |
| 188 | blob_appendf(&snd, "Host: %s:%d\r\n", g.urlHostname, g.proxyOrigPort); |
| 189 | if( g.urlProxyAuth ){ |
| 190 | blob_appendf(&snd, "Proxy-Authorization: %s\r\n", g.urlProxyAuth); |
| 191 | } |
| 192 | blob_append(&snd, "Proxy-Connection: keep-alive\r\n", -1); |
| 193 | blob_append(&snd, "User-Agent: Fossil/" RELEASE_VERSION "\r\n", -1); |
| 194 | blob_append(&snd, "\r\n", 2); |
| 195 | BIO_write(bio, blob_buffer(&snd), blob_size(&snd)); |
| 196 | blob_reset(&snd); |
| 197 | |
| 198 | /* Wait for end of reply */ |
| 199 | blob_zero(&reply); |
| 200 | do{ |
| 201 | int len; |
| 202 |