summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/reqs.c21
2 files changed, 12 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 20d820c..f751dc0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
* src/reqs.c (write_message): Encapsulate code to handle sending
snprintf() built lines to a file descriptor.
+ (process_server_headers): Removed duplicate code and used the
+ return value from readline() instead of recaculating it by
+ strlen().
2001-12-18 Robert James Kaes <rjkaes@flarenet.com>
diff --git a/src/reqs.c b/src/reqs.c
index e1b18f0..edf60e4 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1,4 +1,4 @@
-/* $Id: reqs.c,v 1.48 2001-12-19 05:20:01 rjkaes Exp $
+/* $Id: reqs.c,v 1.49 2001-12-19 20:40:23 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
@@ -702,28 +702,25 @@ static int
process_server_headers(struct conn_s *connptr)
{
char *header;
+ ssize_t len;
- for (;;) {
- if (readline(connptr->server_fd, &header) <= 0) {
+ while (1) {
+ if ((len = readline(connptr->server_fd, &header)) <= 0) {
DEBUG2("Server (file descriptor %d) closed connection.",
connptr->server_fd);
return -1;
}
- if (header[0] == '\n'
- || (header[0] == '\r' && header[1] == '\n')) {
- break;
- }
-
- if (safe_write(connptr->client_fd, header, strlen(header)) < 0) {
+ if (safe_write(connptr->client_fd, header, len) < 0) {
safefree(header);
return -1;
}
- }
- if (safe_write(connptr->client_fd, header, strlen(header)) < 0) {
+ if (header[0] == '\n'
+ || (header[0] == '\r' && header[1] == '\n'))
+ break;
+
safefree(header);
- return -1;
}
safefree(header);