X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/record-dvb/blobdiff_plain/9fbd8130d45c8218eaea28d13f7bf53de0bffa39..e102f6947ff0fa3284ccb675b774560e8ee2454c:/http.c diff --git a/http.c b/http.c index eee7345..c7e553c 100644 --- a/http.c +++ b/http.c @@ -27,17 +27,15 @@ int open_http(char *url) { int fd; struct sockaddr_in server; - static struct dvb_host *dvbhost = NULL; + struct dvb_host *dvbhost = NULL; char c, buffer[BUFFSIZE], *pos; int lines = 0; if(!is_http(url)) return -1; - if (!dvbhost) { - dvbhost = parse(&(url[7]), "80"); - dvbhost->socktype = SOCK_STREAM; - } + dvbhost = parse(&(url[7]), "80"); + dvbhost->socktype = SOCK_STREAM; if (resolve(dvbhost, &server) < 0) { return -1; @@ -91,8 +89,7 @@ int open_http(char *url) pos = buffer; while (*pos != 0) { - if (*pos == ' ') { - pos++; + if (*(pos++) == ' ') { if(strncmp("200", pos, 3)) { fprintf(stderr, "Wrong result-code: %s\n", buffer); return -1; @@ -100,7 +97,11 @@ int open_http(char *url) break; } } - pos++; + + if (*(++pos) == 0) { + fprintf(stderr, "Wrong answer from server: %s\n", buffer); + return -1; + } } }