summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-12-23 21:55:08 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-12-23 21:55:08 +0000
commitc3124815a1f6a9bb441edd77633f4750d4f3c5b6 (patch)
tree613366fc6d940b6c6ca0dff51813ca3b20da2125 /src
parentb68354a9da9a513171332fd7a99da40299d4eb71 (diff)
Cleaned up the code which sends the "Via" header. It now uses
write_message().
Diffstat (limited to 'src')
-rw-r--r--src/reqs.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/reqs.c b/src/reqs.c
index c7b7dcd..da7f72e 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1,4 +1,4 @@
-/* $Id: reqs.c,v 1.50 2001-12-20 04:48:32 rjkaes Exp $
+/* $Id: reqs.c,v 1.51 2001-12-23 21:55:08 rjkaes Exp $
*
* This is where all the work in tinyproxy is actually done. Incoming
* connections have a new thread created for them. The thread then
@@ -9,7 +9,7 @@
* this feature for a buffering NNTP tunnel.)
*
* Copyright (C) 1998 Steven Young
- * Copyright (C) 1999,2000 Robert James Kaes (rjkaes@flarenet.com)
+ * Copyright (C) 1999-2001 Robert James Kaes (rjkaes@flarenet.com)
* Copyright (C) 2000 Chris Lightfoot (chris@ex-parrot.com)
*
* This program is free software; you can redistribute it and/or modify it
@@ -241,6 +241,8 @@ write_message(int fd, const char *fmt, ...)
}
if (safe_write(fd, buf, n) < 0) {
+ DEBUG2("Error in write_message(): %d", fd);
+
safefree(buf);
return -1;
}
@@ -594,28 +596,23 @@ process_client_headers(struct conn_s *connptr)
* to the end of it.
*/
if (strncasecmp(header, "via", 3) == 0) {
- char hostname[128];
- char via_header_buffer[256];
- char *new_header;
-
- sent_via_header = 1;
-
- gethostname(hostname, sizeof(hostname));
- snprintf(via_header_buffer, sizeof(via_header_buffer),
- ", %hu.%hu %s (%s/%s)\r\n",
- connptr->protocol.major,
- connptr->protocol.minor, hostname, PACKAGE,
- VERSION);
-
- chomp(header, strlen(header));
-
- new_header = safemalloc(strlen(header) + strlen(via_header_buffer) + 1);
- strcpy(new_header, header);
- strcat(new_header, via_header_buffer);
-
+ if (sent_via_header == 0) {
+ char hostname[128];
+
+ chomp(header, len);
+ gethostname(hostname, sizeof(hostname));
+ write_message(connptr->server_fd,
+ "%s, %hu.%hu %s (%s/%s)\r\n",
+ header,
+ connptr->protocol.major,
+ connptr->protocol.minor,
+ hostname, PACKAGE, VERSION);
+
+ sent_via_header = 1;
+ }
safefree(header);
- header = new_header;
+ continue;
}
/*
@@ -665,16 +662,14 @@ process_client_headers(struct conn_s *connptr)
/*
* We're the first proxy so send the first Via header.
*/
- char via_header_buffer[256];
char hostname[128];
gethostname(hostname, sizeof(hostname));
- snprintf(via_header_buffer, sizeof(via_header_buffer),
- "Via: %hu.%hu %s (%s/%s)\r\n", connptr->protocol.major,
- connptr->protocol.minor, hostname, PACKAGE, VERSION);
-
- safe_write(connptr->server_fd, via_header_buffer,
- strlen(via_header_buffer));
+ write_message(connptr->server_fd,
+ "Via: %hu.%hu %s (%s/%s)\r\n",
+ connptr->protocol.major,
+ connptr->protocol.minor,
+ hostname, PACKAGE, VERSION);
}
if ((connptr->server_fd != -1)