add support for outgoing connections with HTTP/1.1
since there are numerous changes in HTTP/1.1, the proxyserver will stick to using HTTP/1.0 for internal usage, however when a connection is requested with HTTP/1.x from now on we will duplicate the minor revision the client requested, because apparently some servers refuse to accept HTTP/1.0 addresses #152.
This commit is contained in:
		
							parent
							
								
									979c737f9b
								
							
						
					
					
						commit
						a869e71ac3
					
				@ -138,13 +138,14 @@ int send_http_headers (
 | 
				
			|||||||
        const char *message, const char *extra)
 | 
					        const char *message, const char *extra)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
        const char headers[] =
 | 
					        const char headers[] =
 | 
				
			||||||
            "HTTP/1.0 %d %s\r\n"
 | 
					            "HTTP/1.%u %d %s\r\n"
 | 
				
			||||||
            "Server: %s/%s\r\n"
 | 
					            "Server: %s/%s\r\n"
 | 
				
			||||||
            "Content-Type: text/html\r\n"
 | 
					            "Content-Type: text/html\r\n"
 | 
				
			||||||
            "%s"
 | 
					            "%s"
 | 
				
			||||||
            "Connection: close\r\n" "\r\n";
 | 
					            "Connection: close\r\n" "\r\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return (write_message (connptr->client_fd, headers,
 | 
					        return (write_message (connptr->client_fd, headers,
 | 
				
			||||||
 | 
					                               connptr->protocol.major != 1 ? 0 : connptr->protocol.minor,
 | 
				
			||||||
                               code, message, PACKAGE, VERSION,
 | 
					                               code, message, PACKAGE, VERSION,
 | 
				
			||||||
                               extra));
 | 
					                               extra));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/reqs.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/reqs.c
									
									
									
									
									
								
							@ -268,28 +268,34 @@ establish_http_connection (struct conn_s *connptr, struct request_s *request)
 | 
				
			|||||||
                /* host is an IPv6 address literal, so surround it with
 | 
					                /* host is an IPv6 address literal, so surround it with
 | 
				
			||||||
                 * [] */
 | 
					                 * [] */
 | 
				
			||||||
                return write_message (connptr->server_fd,
 | 
					                return write_message (connptr->server_fd,
 | 
				
			||||||
                                      "%s %s HTTP/1.0\r\n"
 | 
					                                      "%s %s HTTP/1.%u\r\n"
 | 
				
			||||||
                                      "Host: [%s]%s\r\n"
 | 
					                                      "Host: [%s]%s\r\n"
 | 
				
			||||||
                                      "Connection: close\r\n",
 | 
					                                      "Connection: close\r\n",
 | 
				
			||||||
                                      request->method, request->path,
 | 
					                                      request->method, request->path,
 | 
				
			||||||
 | 
					                                      connptr->protocol.major != 1 ? 0 :
 | 
				
			||||||
 | 
					                                               connptr->protocol.minor,
 | 
				
			||||||
                                      request->host, portbuff);
 | 
					                                      request->host, portbuff);
 | 
				
			||||||
        } else if (connptr->upstream_proxy &&
 | 
					        } else if (connptr->upstream_proxy &&
 | 
				
			||||||
                   connptr->upstream_proxy->type == PT_HTTP &&
 | 
					                   connptr->upstream_proxy->type == PT_HTTP &&
 | 
				
			||||||
                   connptr->upstream_proxy->ua.authstr) {
 | 
					                   connptr->upstream_proxy->ua.authstr) {
 | 
				
			||||||
                return write_message (connptr->server_fd,
 | 
					                return write_message (connptr->server_fd,
 | 
				
			||||||
                                      "%s %s HTTP/1.0\r\n"
 | 
					                                      "%s %s HTTP/1.%u\r\n"
 | 
				
			||||||
                                      "Host: %s%s\r\n"
 | 
					                                      "Host: %s%s\r\n"
 | 
				
			||||||
                                      "Connection: close\r\n"
 | 
					                                      "Connection: close\r\n"
 | 
				
			||||||
                                      "Proxy-Authorization: Basic %s\r\n",
 | 
					                                      "Proxy-Authorization: Basic %s\r\n",
 | 
				
			||||||
                                      request->method, request->path,
 | 
					                                      request->method, request->path,
 | 
				
			||||||
 | 
					                                      connptr->protocol.major != 1 ? 0 :
 | 
				
			||||||
 | 
					                                               connptr->protocol.minor,
 | 
				
			||||||
                                      request->host, portbuff,
 | 
					                                      request->host, portbuff,
 | 
				
			||||||
                                      connptr->upstream_proxy->ua.authstr);
 | 
					                                      connptr->upstream_proxy->ua.authstr);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
                return write_message (connptr->server_fd,
 | 
					                return write_message (connptr->server_fd,
 | 
				
			||||||
                                      "%s %s HTTP/1.0\r\n"
 | 
					                                      "%s %s HTTP/1.%u\r\n"
 | 
				
			||||||
                                      "Host: %s%s\r\n"
 | 
					                                      "Host: %s%s\r\n"
 | 
				
			||||||
                                      "Connection: close\r\n",
 | 
					                                      "Connection: close\r\n",
 | 
				
			||||||
                                      request->method, request->path,
 | 
					                                      request->method, request->path,
 | 
				
			||||||
 | 
					                                      connptr->protocol.major != 1 ? 0 :
 | 
				
			||||||
 | 
					                                               connptr->protocol.minor,
 | 
				
			||||||
                                      request->host, portbuff);
 | 
					                                      request->host, portbuff);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user