#if 0'd the code handling the "Via" header in the process_client_headers()
function since I'm not completely happy with the code.
This commit is contained in:
		
							parent
							
								
									bc8c3ff399
								
							
						
					
					
						commit
						a30eb425e3
					
				
							
								
								
									
										28
									
								
								src/reqs.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/reqs.c
									
									
									
									
									
								
							@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: reqs.c,v 1.38 2001-11-21 00:59:33 rjkaes Exp $
 | 
					/* $Id: reqs.c,v 1.39 2001-11-21 19:19:46 rjkaes Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * This is where all the work in tinyproxy is actually done. Incoming
 | 
					 * This is where all the work in tinyproxy is actually done. Incoming
 | 
				
			||||||
 * connections have a new thread created for them. The thread then
 | 
					 * connections have a new thread created for them. The thread then
 | 
				
			||||||
@ -214,6 +214,13 @@ static int establish_http_connection(struct conn_s *connptr,
 | 
				
			|||||||
	if (safe_write(connptr->server_fd, "\r\n", 2) < 0)
 | 
						if (safe_write(connptr->server_fd, "\r\n", 2) < 0)
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Send the Connection header since we don't support persistant
 | 
				
			||||||
 | 
						 * connections.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (safe_write(connptr->server_fd, "Connection: close\r\n", 19) < 0)
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -447,6 +454,12 @@ static int add_xtinyproxy_header(struct conn_s *connptr)
 | 
				
			|||||||
	char xtinyproxy[32];
 | 
						char xtinyproxy[32];
 | 
				
			||||||
	int length;
 | 
						int length;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Don't try to send if we have an invalid server handle.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (connptr->server_fd == -1)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	length = snprintf(xtinyproxy, sizeof(xtinyproxy),
 | 
						length = snprintf(xtinyproxy, sizeof(xtinyproxy),
 | 
				
			||||||
			  "X-Tinyproxy: %s\r\n",
 | 
								  "X-Tinyproxy: %s\r\n",
 | 
				
			||||||
			  getpeer_ip(connptr->client_fd, ipaddr));
 | 
								  getpeer_ip(connptr->client_fd, ipaddr));
 | 
				
			||||||
@ -467,10 +480,13 @@ static int process_client_headers(struct conn_s *connptr)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	char *header;
 | 
						char *header;
 | 
				
			||||||
	long content_length = -1;
 | 
						long content_length = -1;
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
	short int sent_via_header = 0;
 | 
						short int sent_via_header = 0;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static char *skipheaders[] = {
 | 
						static char *skipheaders[] = {
 | 
				
			||||||
		"proxy-connection",
 | 
							"proxy-connection",
 | 
				
			||||||
 | 
							"host",
 | 
				
			||||||
		"keep-alive",
 | 
							"keep-alive",
 | 
				
			||||||
		"proxy-authenticate",
 | 
							"proxy-authenticate",
 | 
				
			||||||
		"proxy-authorization",
 | 
							"proxy-authorization",
 | 
				
			||||||
@ -484,6 +500,7 @@ static int process_client_headers(struct conn_s *connptr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for ( ; ; ) {
 | 
						for ( ; ; ) {
 | 
				
			||||||
		if (readline(connptr->client_fd, header, LINE_LENGTH) <= 0) {
 | 
							if (readline(connptr->client_fd, header, LINE_LENGTH) <= 0) {
 | 
				
			||||||
 | 
								DEBUG2("Client (file descriptor %d) closed connection.", connptr->client_fd);
 | 
				
			||||||
			safefree(header);
 | 
								safefree(header);
 | 
				
			||||||
			return -1;
 | 
								return -1;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -503,6 +520,7 @@ static int process_client_headers(struct conn_s *connptr)
 | 
				
			|||||||
		if (connptr->ssl && !connptr->upstream)
 | 
							if (connptr->ssl && !connptr->upstream)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * If we find a Via header we need to append our information
 | 
							 * If we find a Via header we need to append our information
 | 
				
			||||||
		 * to the end of it.
 | 
							 * to the end of it.
 | 
				
			||||||
@ -520,6 +538,7 @@ static int process_client_headers(struct conn_s *connptr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			strlcat(header, via_header_buffer, LINE_LENGTH);
 | 
								strlcat(header, via_header_buffer, LINE_LENGTH);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					#endif 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * Don't send certain headers.
 | 
							 * Don't send certain headers.
 | 
				
			||||||
@ -541,12 +560,13 @@ static int process_client_headers(struct conn_s *connptr)
 | 
				
			|||||||
			content_length = atol(content_ptr);
 | 
								content_length = atol(content_ptr);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
 | 
							if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
 | 
				
			||||||
			safefree(header);
 | 
								safefree(header);
 | 
				
			||||||
			return -1;
 | 
								return -1;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
	if (sent_via_header == 0) {
 | 
						if (sent_via_header == 0) {
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * We're the first proxy so send the first Via header.
 | 
							 * We're the first proxy so send the first Via header.
 | 
				
			||||||
@ -559,6 +579,7 @@ static int process_client_headers(struct conn_s *connptr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		safe_write(connptr->server_fd, via_header_buffer, strlen(via_header_buffer));
 | 
							safe_write(connptr->server_fd, via_header_buffer, strlen(via_header_buffer));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!connptr->send_message && (connptr->upstream || !connptr->ssl)) {
 | 
						if (!connptr->send_message && (connptr->upstream || !connptr->ssl)) {
 | 
				
			||||||
#ifdef XTINYPROXY_ENABLE
 | 
					#ifdef XTINYPROXY_ENABLE
 | 
				
			||||||
@ -569,7 +590,7 @@ static int process_client_headers(struct conn_s *connptr)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
#endif	/* XTINYPROXY */
 | 
					#endif	/* XTINYPROXY */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (safe_write(connptr->server_fd, header, strlen(header)) < 0) {
 | 
							if ((connptr->server_fd != -1) && safe_write(connptr->server_fd, header, strlen(header)) < 0) {
 | 
				
			||||||
			safefree(header);
 | 
								safefree(header);
 | 
				
			||||||
			return -1;
 | 
								return -1;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -600,6 +621,7 @@ static int process_server_headers(struct conn_s *connptr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for ( ; ; ) {
 | 
						for ( ; ; ) {
 | 
				
			||||||
		if (readline(connptr->server_fd, header, LINE_LENGTH) <= 0) {
 | 
							if (readline(connptr->server_fd, header, LINE_LENGTH) <= 0) {
 | 
				
			||||||
 | 
								DEBUG2("Server (file descriptor %d) closed connection.", connptr->server_fd);
 | 
				
			||||||
			safefree(header);
 | 
								safefree(header);
 | 
				
			||||||
			return -1;
 | 
								return -1;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user