summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2002-05-28 04:53:33 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2002-05-28 04:53:33 +0000
commitcf2bd809fbc738eb383f7598a1f38f3f3e81f5fa (patch)
tree61592ead17ad73dab4722a674bebbf3a0414661b
parent00bf9b03465a6059b86036a6905e27335691dcf9 (diff)
downloadtinyproxy-cf2bd809fbc738eb383f7598a1f38f3f3e81f5fa.tar.gz
tinyproxy-cf2bd809fbc738eb383f7598a1f38f3f3e81f5fa.zip
(get_all_headers): Added code to ignore a "response" line in a header. This was pointed out as being a problem with eBay (cgi.ebay.com)
(process_server_headers): Added code to make skip blank lines before a response line.
-rw-r--r--src/reqs.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/reqs.c b/src/reqs.c
index d7ebc56..8dd38d9 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1,4 +1,4 @@
-/* $Id: reqs.c,v 1.77 2002-05-27 02:00:22 rjkaes Exp $
+/* $Id: reqs.c,v 1.78 2002-05-28 04:53:33 rjkaes Exp $
*
* This is where all the work in tinyproxy is actually done. Incoming
* connections have a new child created for them. The child then
@@ -560,6 +560,9 @@ get_all_headers(int fd, hashmap_t hashofheaders)
char *header;
ssize_t len;
+ assert(fd >= 0);
+ assert(hashofheaders != NULL);
+
for (;;) {
if ((len = readline(fd, &header)) <= 0) {
safefree(header);
@@ -575,6 +578,17 @@ get_all_headers(int fd, hashmap_t hashofheaders)
return 0;
}
+ /*
+ * BUG FIX: Need this code to skip a second "HTTP/1.x ... OK"
+ * response. This was needed because of cgi.ebay.com.
+ *
+ * FIXME: Might need to change this to a more robust check.
+ */
+ if (strncasecmp(header, "HTTP/", 5) == 0) {
+ safefree(header);
+ continue;
+ }
+
if (add_header_to_connection(hashofheaders, header, len) < 0) {
safefree(header);
return -1;
@@ -857,9 +871,24 @@ process_server_headers(struct conn_s *connptr)
/* FIXME: Remember to handle a "simple_req" type */
/* Get the response line from the remote server. */
- if ((len = readline(connptr->server_fd, &response_line)) <= 0)
+ retry:
+ len = readline(connptr->server_fd, &response_line);
+ if (len <= 0)
return -1;
+ /*
+ * Strip the new line and character return from the string.
+ */
+ if (chomp(response_line, len) == len) {
+ /*
+ * If the number of characters removed is the same as the
+ * length then it was a blank line. Free the buffer and
+ * try again (since we're looking for a request line.)
+ */
+ safefree(response_line);
+ goto retry;
+ }
+
hashofheaders = hashmap_create(HEADER_BUCKETS);
if (!hashofheaders) {
safefree(response_line);