summaryrefslogtreecommitdiffstats
path: root/usr.bin/fetch
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-06-25 21:33:18 +0000
committerache <ache@FreeBSD.org>1996-06-25 21:33:18 +0000
commitc9f677c96f88ec47e35a27bddf8a4465820f8075 (patch)
treeffb714eeebb9a7e2c8f8e5c1a1db4334d7f4e535 /usr.bin/fetch
parent40797deb0ee0085d5485507596c54d6d823a8246 (diff)
downloadFreeBSD-src-c9f677c96f88ec47e35a27bddf8a4465820f8075.zip
FreeBSD-src-c9f677c96f88ec47e35a27bddf8a4465820f8075.tar.gz
Make GET request and response parsing HTTP/1.0 compatible
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r--usr.bin/fetch/main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c
index dca950a..3ab49a8 100644
--- a/usr.bin/fetch/main.c
+++ b/usr.bin/fetch/main.c
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
-/* $Id: main.c,v 1.4 1996/06/22 23:24:13 jkh Exp $ */
+/* $Id: main.c,v 1.5 1996/06/24 01:03:05 jmz Exp $ */
#include <stdlib.h>
#include <stdio.h>
@@ -469,7 +469,7 @@ httpget ()
restart = 0;
s = http_open ();
- sprintf (str, "GET /%s\n", file_to_get);
+ sprintf (str, "GET /%s HTTP/1.0\n\n", file_to_get);
i = strlen (str);
if (i != write (s, str, i))
err (1, 0);
@@ -525,7 +525,7 @@ match (char *pat, char *s)
void
filter (unsigned char *p, int len)
{
-#define S 250
+#define S 512
static unsigned char s[S+2];
static int header_len = 0, size = -1, n;
int i = len;
@@ -537,10 +537,10 @@ filter (unsigned char *p, int len)
s[header_len] = 0;
if (len && (header_len < S))
return;
- if (match (".*200.*success", s) == 0) {
+ if (match ("^HTTP/[0-9]+\\.[0-9]+[ \t]+200[^0-9]", s) == 0) {
/* maybe not found, or document w/o header */
- if (match (".*404.*not found", s)) {
- fprintf (stderr, "%s not found\n%s\n", file_to_get, s);
+ if (match ("^HTTP/[0-9]+\\.[0-9]+[ \t]+[0-9]+", s)) {
+ fprintf (stderr, "%s fetching failed, header so far:\n%s\n", file_to_get, s);
rm ();
exit (1);
}
@@ -561,7 +561,7 @@ filter (unsigned char *p, int len)
} else {
unsigned char *t;
/* document begins with a success line. try to get size */
- i = match ("content-length: *([0-9]+)", s);
+ i = match ("content-length:[ \t]*([0-9]+)", s);
if (i > 0)
size = atoi (s+i);
/* assume that the file to get begins after an empty line */
OpenPOWER on IntegriCloud