From 93f0406b7e2af65aa416fffb1a8a2aaacdb0d10d Mon Sep 17 00:00:00 2001 From: Robert James Kaes Date: Thu, 20 Dec 2001 04:48:32 +0000 Subject: Created the CHECK_CRLF() macro to handle the tests for the appropriate control characters in a string. --- src/reqs.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/reqs.c b/src/reqs.c index edf60e4..c7b7dcd 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -1,4 +1,4 @@ -/* $Id: reqs.c,v 1.49 2001-12-19 20:40:23 rjkaes Exp $ +/* $Id: reqs.c,v 1.50 2001-12-20 04:48:32 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 @@ -65,6 +65,11 @@ # define TUNNEL_CONFIGURED() (0) #endif +/* + * Codify the test for the carriage return and new line characters. + */ +#define CHECK_CRLF(header, len) ((len == 1 && header[0] == '\n') || (len == 2 && header[0] == '\r' && header[1] == '\n')) + /* * Read in the first line from the client (the request line for HTTP * connections. The request line is allocated from the heap, but it must @@ -570,10 +575,8 @@ process_client_headers(struct conn_s *connptr) * If we receive a CR LF (or just a LF) on a line by itself, * the headers are finished. */ - if ((len == 1 && header[0] == '\n') - || (len == 2 && header[0] == '\r' && header[1] == '\n')) { + if (CHECK_CRLF(header, len)) break; - } /* * Don't send headers if there's already an error, or if @@ -716,8 +719,7 @@ process_server_headers(struct conn_s *connptr) return -1; } - if (header[0] == '\n' - || (header[0] == '\r' && header[1] == '\n')) + if (CHECK_CRLF(header, len)) break; safefree(header); -- cgit v1.2.3