]>
cvs.zerfleddert.de Git - record-dvb/blob - http.c
6 #include <sys/socket.h>
7 #include <netinet/in.h>
15 int is_http(char *url
)
20 if (!strncasecmp("http://",url
,7))
26 int open_http(char *url
)
29 struct sockaddr_in server
;
30 static struct dvb_host
*dvbhost
= NULL
;
31 char buffer
[BUFFSIZE
];
38 dvbhost
= parse(&(url
[7]), "80");
39 dvbhost
->socktype
= SOCK_STREAM
;
42 if (resolve(dvbhost
, &server
) < 0) {
46 if ((fd
= socket(AF_INET
, SOCK_STREAM
, IPPROTO_TCP
)) < 0) {
51 if (connect(fd
, (struct sockaddr
*) &server
, sizeof(server
)) < 0) {
56 snprintf(buffer
, BUFFSIZE
-1, "GET /%s HTTP/1.0\n\n",dvbhost
->location
);
57 buffer
[BUFFSIZE
-1] = 0;
58 send(fd
, buffer
, strlen(buffer
), 0);
61 if (recv(fd
, buffer
, 1, 0) < 1) {
65 printf("%c",buffer
[0]);
66 if (buffer
[0] == 0x0a)
69 if (buffer
[0] != 0x0d)