diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:21 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:21 -0800 |
commit | c2db2b6accc7888df514261a7240e7759df95a4c (patch) | |
tree | 0d7ecd37a534c15348cbad01d0d1f84183b7b4d8 /proxy/proxy_http_connector.c | |
parent | df7881f07f53b041dc0568be8528e9dbb74994cc (diff) | |
download | external_qemu-c2db2b6accc7888df514261a7240e7759df95a4c.zip external_qemu-c2db2b6accc7888df514261a7240e7759df95a4c.tar.gz external_qemu-c2db2b6accc7888df514261a7240e7759df95a4c.tar.bz2 |
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'proxy/proxy_http_connector.c')
-rw-r--r-- | proxy/proxy_http_connector.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/proxy/proxy_http_connector.c b/proxy/proxy_http_connector.c index 1b2ba3e..7bf2f53 100644 --- a/proxy/proxy_http_connector.c +++ b/proxy/proxy_http_connector.c @@ -52,35 +52,25 @@ connection_init( Connection* conn ) HttpService* service = (HttpService*) conn->root->service; ProxyConnection* root = conn->root; stralloc_t* str = root->str; - int ret; - uint32_t address = ntohl(root->address.sin_addr.s_addr); - int port = ntohs(root->address.sin_port); proxy_connection_rewind(root); - stralloc_add_format(str, "CONNECT %d.%d.%d.%d:%d HTTP/" HTTP_VERSION "\r\n", - (address >> 24) & 0xff, (address >> 16) & 0xff, - (address >> 8) & 0xff, address & 0xff, port); + stralloc_add_format(str, "CONNECT %s HTTP/" HTTP_VERSION "\r\n", + sock_address_to_string(&root->address)); stralloc_add_bytes(str, service->footer, service->footer_len); - do { - ret = connect( root->socket, - (struct sockaddr*) &service->server_addr, - sizeof(service->server_addr) ); - } while (ret < 0 && socket_errno == EINTR); - - if (ret == 0) { + if (!socket_connect( root->socket, &service->server_addr )) { /* immediate connection ?? */ conn->state = STATE_SEND_HEADER; PROXY_LOG("%s: immediate connection", root->name); } else { - if (socket_errno == EINPROGRESS || socket_errno == EWOULDBLOCK) { + if (errno == EINPROGRESS || errno == EWOULDBLOCK) { conn->state = STATE_CONNECTING; PROXY_LOG("%s: connecting", root->name); } else { - PROXY_LOG("%s: cannot connect to proxy: %s", root->name, socket_errstr()); + PROXY_LOG("%s: cannot connect to proxy: %s", root->name, errno_str); return -1; } } @@ -183,13 +173,13 @@ connection_poll( ProxyConnection* root, ProxyConnection* -http_connector_connect( HttpService* service, - struct sockaddr_in* address ) +http_connector_connect( HttpService* service, + SockAddress* address ) { Connection* conn; int s; - s = socket(AF_INET, SOCK_STREAM, 0); + s = socket_create_inet( SOCKET_STREAM ); if (s < 0) return NULL; |