|  | @@ -237,6 +237,7 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
 | 
		
	
		
			
			| 237 | 237 |  	struct http_scheme *scheme;
 | 
		
	
		
			
			| 238 | 238 |  	struct sockaddr_tcpip server;
 | 
		
	
		
			
			| 239 | 239 |  	struct interface *socket;
 | 
		
	
		
			
			|  | 240 | +	unsigned int port;
 | 
		
	
		
			
			| 240 | 241 |  	int rc;
 | 
		
	
		
			
			| 241 | 242 |  
 | 
		
	
		
			
			| 242 | 243 |  	/* Identify scheme */
 | 
		
	
	
		
			
			|  | @@ -248,6 +249,9 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
 | 
		
	
		
			
			| 248 | 249 |  	if ( ! uri->host )
 | 
		
	
		
			
			| 249 | 250 |  		return -EINVAL;
 | 
		
	
		
			
			| 250 | 251 |  
 | 
		
	
		
			
			|  | 252 | +	/* Identify port */
 | 
		
	
		
			
			|  | 253 | +	port = uri_port ( uri, scheme->port );
 | 
		
	
		
			
			|  | 254 | +
 | 
		
	
		
			
			| 251 | 255 |  	/* Look for a reusable connection in the pool */
 | 
		
	
		
			
			| 252 | 256 |  	list_for_each_entry ( conn, &http_connection_pool, pool.list ) {
 | 
		
	
		
			
			| 253 | 257 |  
 | 
		
	
	
		
			
			|  | @@ -257,15 +261,16 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
 | 
		
	
		
			
			| 257 | 261 |  
 | 
		
	
		
			
			| 258 | 262 |  		/* Reuse connection, if possible */
 | 
		
	
		
			
			| 259 | 263 |  		if ( ( scheme == conn->scheme ) &&
 | 
		
	
		
			
			| 260 |  | -		     ( strcmp ( uri->host, conn->uri->host ) == 0 ) ) {
 | 
		
	
		
			
			|  | 264 | +		     ( strcmp ( uri->host, conn->uri->host ) == 0 ) &&
 | 
		
	
		
			
			|  | 265 | +		     ( port == uri_port ( conn->uri, scheme->port ) ) ) {
 | 
		
	
		
			
			| 261 | 266 |  
 | 
		
	
		
			
			| 262 | 267 |  			/* Remove from connection pool, stop timer,
 | 
		
	
		
			
			| 263 | 268 |  			 * attach to parent interface, and return.
 | 
		
	
		
			
			| 264 | 269 |  			 */
 | 
		
	
		
			
			| 265 | 270 |  			pool_del ( &conn->pool );
 | 
		
	
		
			
			| 266 | 271 |  			intf_plug_plug ( &conn->xfer, xfer );
 | 
		
	
		
			
			| 267 |  | -			DBGC2 ( conn, "HTTPCONN %p reused %s://%s\n",
 | 
		
	
		
			
			| 268 |  | -				conn, conn->scheme->name, conn->uri->host );
 | 
		
	
		
			
			|  | 272 | +			DBGC2 ( conn, "HTTPCONN %p reused %s://%s:%d\n", conn,
 | 
		
	
		
			
			|  | 273 | +				conn->scheme->name, conn->uri->host, port );
 | 
		
	
		
			
			| 269 | 274 |  			return 0;
 | 
		
	
		
			
			| 270 | 275 |  		}
 | 
		
	
		
			
			| 271 | 276 |  	}
 | 
		
	
	
		
			
			|  | @@ -281,7 +286,7 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
 | 
		
	
		
			
			| 281 | 286 |  
 | 
		
	
		
			
			| 282 | 287 |  	/* Open socket */
 | 
		
	
		
			
			| 283 | 288 |  	memset ( &server, 0, sizeof ( server ) );
 | 
		
	
		
			
			| 284 |  | -	server.st_port = htons ( uri_port ( uri, scheme->port ) );
 | 
		
	
		
			
			|  | 289 | +	server.st_port = htons ( port );
 | 
		
	
		
			
			| 285 | 290 |  	socket = &conn->socket;
 | 
		
	
		
			
			| 286 | 291 |  	if ( scheme->filter &&
 | 
		
	
		
			
			| 287 | 292 |  	     ( ( rc = scheme->filter ( socket, uri->host, &socket ) ) != 0 ) )
 | 
		
	
	
		
			
			|  | @@ -296,13 +301,13 @@ int http_connect ( struct interface *xfer, struct uri *uri ) {
 | 
		
	
		
			
			| 296 | 301 |  	ref_put ( &conn->refcnt );
 | 
		
	
		
			
			| 297 | 302 |  
 | 
		
	
		
			
			| 298 | 303 |  	DBGC2 ( conn, "HTTPCONN %p created %s://%s:%d\n", conn,
 | 
		
	
		
			
			| 299 |  | -		conn->scheme->name, conn->uri->host, ntohs ( server.st_port ) );
 | 
		
	
		
			
			|  | 304 | +		conn->scheme->name, conn->uri->host, port );
 | 
		
	
		
			
			| 300 | 305 |  	return 0;
 | 
		
	
		
			
			| 301 | 306 |  
 | 
		
	
		
			
			| 302 | 307 |   err_open:
 | 
		
	
		
			
			| 303 | 308 |   err_filter:
 | 
		
	
		
			
			| 304 |  | -	DBGC2 ( conn, "HTTPCONN %p could not create %s://%s: %s\n",
 | 
		
	
		
			
			| 305 |  | -		conn, conn->scheme->name, conn->uri->host, strerror ( rc ) );
 | 
		
	
		
			
			|  | 309 | +	DBGC2 ( conn, "HTTPCONN %p could not create %s://%s:%d: %s\n", conn,
 | 
		
	
		
			
			|  | 310 | +		conn->scheme->name, conn->uri->host, port, strerror ( rc ) );
 | 
		
	
		
			
			| 306 | 311 |  	http_conn_close ( conn, rc );
 | 
		
	
		
			
			| 307 | 312 |  	ref_put ( &conn->refcnt );
 | 
		
	
		
			
			| 308 | 313 |  	return rc;
 |