Audio-Play-MPG123
view release on metacpan or search on metacpan
mpg123/httpget.c view on Meta::CPAN
char *httpauth = NULL;
char httpauth1[256];
int http_open (char *url)
{
char *purl, *host, *request, *sptr;
int linelength;
unsigned long myip;
unsigned char *myport;
int sock;
int relocate, numrelocs = 0;
FILE *myfile;
#ifdef INET6
struct addrinfo hints, *res, *res0;
int error;
#else
struct hostent *hp;
struct sockaddr_in sin;
#endif
host = NULL;
mpg123/httpget.c view on Meta::CPAN
strcat (request,buf);
strcat (request,"\r\n");
}
strcat (request, "\r\n");
writestring (sock, request);
if (!(myfile = fdopen(sock, "rb"))) {
perror ("fdopen");
exit (1);
};
relocate = FALSE;
purl[0] = '\0';
readstring (request, linelength-1, myfile);
if ((sptr = strchr(request, ' '))) {
switch (sptr[1]) {
case '3':
relocate = TRUE;
case '2':
break;
default:
fprintf (stderr, "HTTP request failed: %s",
sptr+1); /* '\n' is included */
exit (1);
}
}
do {
readstring (request, linelength-1, myfile);
if (!strncmp(request, "Location:", 9))
strncpy (purl, request+10, 1023);
} while (request[0] != '\r' && request[0] != '\n');
} while (relocate && purl[0] && numrelocs++ < 5);
if (relocate) {
fprintf (stderr, "Too many HTTP relocations.\n");
exit (1);
}
free (purl);
free (request);
free(host);
free(proxyport);
free(myport);
return sock;
}
( run in 1.703 second using v1.01-cache-2.11-cpan-71847e10f99 )