static int http_connect(URLContext *h, const char *path, const char *hoststr)

{

    HTTPContext *s = h->priv_data;

    int post, err, ch;

    char line[1024], *q;





    /* send http header */

    post = h->flags & URL_WRONLY;



    snprintf(s->buffer, sizeof(s->buffer),

             "%s %s HTTP/1.0\r\n"

             "User-Agent: %s\r\n"

             "Accept: */*\r\n"

             "Host: %s\r\n"

             "\r\n",

             post ? "POST" : "GET",

             path,

             LIBAVFORMAT_IDENT,

             hoststr);

    

    if (http_write(h, s->buffer, strlen(s->buffer)) < 0)

        return AVERROR_IO;

        

    /* init input buffer */

    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->location[0] = '\0';

    if (post) {

        sleep(1);

        return 0;

    }

    

    /* wait for header */

    q = line;

    for(;;) {

        ch = http_getc(s);

        if (ch < 0)

            return AVERROR_IO;

        if (ch == '\n') {

            /* process line */

            if (q > line && q[-1] == '\r')

                q--;

            *q = '\0';

#ifdef DEBUG

            printf("header='%s'\n", line);

#endif

            err = process_line(s, line, s->line_count);

            if (err < 0)

                return err;

            if (err == 0)

                return 0;

            s->line_count++;

            q = line;

        } else {

            if ((q - line) < sizeof(line) - 1)

                *q++ = ch;

        }

    }

}

static int http_connect(URLContext *h, const char *path, const char *hoststr)

{

    HTTPContext *s = h->priv_data;

    int post, err, ch;

    char line[1024], *q;





    

    post = h->flags & URL_WRONLY;



    snprintf(s->buffer, sizeof(s->buffer),

             "%s %s HTTP/1.0\r\n"

             "User-Agent: %s\r\n"

             "Accept: *























    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->location[0] = '\0';

    if (post) {

        sleep(1);

        return 0;

    }

    

    

    q = line;

    for(;;) {

        ch = http_getc(s);

        if (ch < 0)

            return AVERROR_IO;

        if (ch == '\n') {

            

            if (q > line && q[-1] == '\r')

                q--;

            *q = '\0';

#ifdef DEBUG

            printf("header='%s'\n", line);

#endif

            err = process_line(s, line, s->line_count);

            if (err < 0)

                return err;

            if (err == 0)

                return 0;

            s->line_count++;

            q = line;

        } else {

            if ((q - line) < sizeof(line) - 1)

                *q++ = ch;

        }

    }

}

static int FUNC_0(URLContext *VAR_0, const char *VAR_1, const char *VAR_2)

{

    HTTPContext *s = VAR_0->priv_data;

    int VAR_3, VAR_4, VAR_5;

    char VAR_6[1024], *VAR_7;





    

    VAR_3 = VAR_0->flags & URL_WRONLY;



    snprintf(s->buffer, sizeof(s->buffer),

             "%s %s HTTP/1.0\r\n"

             "User-Agent: %s\r\n"

             "Accept: *























    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->location[0] = '\0';

    if (VAR_3) {

        sleep(1);

        return 0;

    }

    

    

    VAR_7 = VAR_6;

    for(;;) {

        VAR_5 = http_getc(s);

        if (VAR_5 < 0)

            return AVERROR_IO;

        if (VAR_5 == '\n') {

            

            if (VAR_7 > VAR_6 && VAR_7[-1] == '\r')

                VAR_7--;

            *VAR_7 = '\0';

#ifdef DEBUG

            printf("header='%s'\n", VAR_6);

#endif

            VAR_4 = process_line(s, VAR_6, s->line_count);

            if (VAR_4 < 0)

                return VAR_4;

            if (VAR_4 == 0)

                return 0;

            s->line_count++;

            VAR_7 = VAR_6;

        } else {

            if ((VAR_7 - VAR_6) < sizeof(VAR_6) - 1)

                *VAR_7++ = VAR_5;

        }

    }

}

static int FUNC_0(URLContext *VAR_0, const char *VAR_1, const char *VAR_2)
{ HTTPContext *s = VAR_0->priv_data; int VAR_3, VAR_4, VAR_5; char VAR_6[1024], *VAR_7; VAR_3 = VAR_0->flags & URL_WRONLY; snprintf(s->buffer, sizeof(s->buffer),
"%s %s HTTP/1.0\r\n"
"User-Agent: %s\r\n"
"Accept: *
s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->location[0] = '\0'; if (VAR_3) { sleep(1); return 0; } VAR_7 = VAR_6; for(;;) { VAR_5 = http_getc(s); if (VAR_5 < 0)
return AVERROR_IO; if (VAR_5 == '\n') { if (VAR_7 > VAR_6 && VAR_7[-1] == '\r')
VAR_7--; *VAR_7 = '\0'; #ifdef DEBUG
printf("header='%s'\n", VAR_6); #endif
VAR_4 = process_line(s, VAR_6, s->line_count); if (VAR_4 < 0)
return VAR_4; if (VAR_4 == 0)
return 0; s->line_count++; VAR_7 = VAR_6; } else { if ((VAR_7 - VAR_6) < sizeof(VAR_6) - 1)
*VAR_7++ = VAR_5; } } }