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

                        const char *auth, int *new_location)

{

    HTTPContext *s = h->priv_data;

    int post, err;

    char line[1024];

    char headers[1024] = "";

    char *authstr = NULL;

    int64_t off = s->off;

    int len = 0;





    /* send http header */

    post = h->flags & URL_WRONLY;

    authstr = ff_http_auth_create_response(&s->auth_state, auth, path,

                                        post ? "POST" : "GET");



    /* set default headers if needed */

    if (!has_header(s->headers, "\r\nUser-Agent: "))

       len += av_strlcatf(headers + len, sizeof(headers) - len,

                          "User-Agent: %s\r\n", LIBAVFORMAT_IDENT);

    if (!has_header(s->headers, "\r\nAccept: "))

        len += av_strlcpy(headers + len, "Accept: */*\r\n",

                          sizeof(headers) - len);

    if (!has_header(s->headers, "\r\nRange: "))

        len += av_strlcatf(headers + len, sizeof(headers) - len,

                           "Range: bytes=%"PRId64"-\r\n", s->off);

    if (!has_header(s->headers, "\r\nConnection: "))

        len += av_strlcpy(headers + len, "Connection: close\r\n",

                          sizeof(headers)-len);

    if (!has_header(s->headers, "\r\nHost: "))

        len += av_strlcatf(headers + len, sizeof(headers) - len,

                           "Host: %s\r\n", hoststr);



    /* now add in custom headers */

    av_strlcpy(headers+len, s->headers, sizeof(headers)-len);



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

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

             "%s"

             "%s"

             "%s"

             "\r\n",

             post ? "POST" : "GET",

             path,

             post && s->is_chunked ? "Transfer-Encoding: chunked\r\n" : "",

             headers,

             authstr ? authstr : "");



    av_freep(&authstr);

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

        return AVERROR(EIO);



    /* init input buffer */

    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->off = 0;

    s->filesize = -1;

    if (post) {

        /* always use chunked encoding for upload data */

        s->chunksize = 0;

        /* Pretend that it did work. We didn't read any header yet, since

         * we've still to send the POST data, but the code calling this

         * function will check http_code after we return. */

        s->http_code = 200;

        return 0;

    }



    /* wait for header */

    for(;;) {

        if (http_get_line(s, line, sizeof(line)) < 0)

            return AVERROR(EIO);



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



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

        if (err < 0)

            return err;

        if (err == 0)

            break;

        s->line_count++;

    }



    return (off == s->off) ? 0 : -1;

}

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

                        const char *auth, int *new_location)

{

    HTTPContext *s = h->priv_data;

    int post, err;

    char line[1024];

    char headers[1024] = "";

    char *authstr = NULL;

    int64_t off = s->off;

    int len = 0;





    

    post = h->flags & URL_WRONLY;

    authstr = ff_http_auth_create_response(&s->auth_state, auth, path,

                                        post ? "POST" : "GET");



    

    if (!has_header(s->headers, "\r\nUser-Agent: "))

       len += av_strlcatf(headers + len, sizeof(headers) - len,

                          "User-Agent: %s\r\n", LIBAVFORMAT_IDENT);

    if (!has_header(s->headers, "\r\nAccept: "))

        len += av_strlcpy(headers + len, "Accept: *

























    av_strlcpy(headers+len, s->headers, sizeof(headers)-len);



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

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

             "%s"

             "%s"

             "%s"

             "\r\n",

             post ? "POST" : "GET",

             path,

             post && s->is_chunked ? "Transfer-Encoding: chunked\r\n" : "",

             headers,

             authstr ? authstr : "");



    av_freep(&authstr);

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

        return AVERROR(EIO);



    

    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->off = 0;

    s->filesize = -1;

    if (post) {

        

        s->chunksize = 0;

        





        s->http_code = 200;

        return 0;

    }



    

    for(;;) {

        if (http_get_line(s, line, sizeof(line)) < 0)

            return AVERROR(EIO);



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



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

        if (err < 0)

            return err;

        if (err == 0)

            break;

        s->line_count++;

    }



    return (off == s->off) ? 0 : -1;

}

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

                        const char *VAR_3, int *VAR_4)

{

    HTTPContext *s = VAR_0->priv_data;

    int VAR_5, VAR_6;

    char VAR_7[1024];

    char VAR_8[1024] = "";

    char *VAR_9 = NULL;

    int64_t off = s->off;

    int VAR_10 = 0;





    

    VAR_5 = VAR_0->flags & URL_WRONLY;

    VAR_9 = ff_http_auth_create_response(&s->auth_state, VAR_3, VAR_1,

                                        VAR_5 ? "POST" : "GET");



    

    if (!has_header(s->VAR_8, "\r\nUser-Agent: "))

       VAR_10 += av_strlcatf(VAR_8 + VAR_10, sizeof(VAR_8) - VAR_10,

                          "User-Agent: %s\r\n", LIBAVFORMAT_IDENT);

    if (!has_header(s->VAR_8, "\r\nAccept: "))

        VAR_10 += av_strlcpy(VAR_8 + VAR_10, "Accept: *

























    av_strlcpy(VAR_8+VAR_10, s->VAR_8, sizeof(VAR_8)-VAR_10);



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

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

             "%s"

             "%s"

             "%s"

             "\r\n",

             VAR_5 ? "POST" : "GET",

             VAR_1,

             VAR_5 && s->is_chunked ? "Transfer-Encoding: chunked\r\n" : "",

             VAR_8,

             VAR_9 ? VAR_9 : "");



    av_freep(&VAR_9);

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

        return AVERROR(EIO);



    

    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->off = 0;

    s->filesize = -1;

    if (VAR_5) {

        

        s->chunksize = 0;

        





        s->http_code = 200;

        return 0;

    }



    

    for(;;) {

        if (http_get_line(s, VAR_7, sizeof(VAR_7)) < 0)

            return AVERROR(EIO);



        dprintf(NULL, "header='%s'\n", VAR_7);



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

        if (VAR_6 < 0)

            return VAR_6;

        if (VAR_6 == 0)

            break;

        s->line_count++;

    }



    return (off == s->off) ? 0 : -1;

}

static int FUNC_0(URLContext *VAR_0, const char *VAR_1, const char *VAR_2,
const char *VAR_3, int *VAR_4)
{ HTTPContext *s = VAR_0->priv_data; int VAR_5, VAR_6; char VAR_7[1024]; char VAR_8[1024] = ""; char *VAR_9 = NULL; int64_t off = s->off; int VAR_10 = 0; VAR_5 = VAR_0->flags & URL_WRONLY; VAR_9 = ff_http_auth_create_response(&s->auth_state, VAR_3, VAR_1,
VAR_5 ? "POST" : "GET"); if (!has_header(s->VAR_8, "\r\nUser-Agent: "))
VAR_10 += av_strlcatf(VAR_8 + VAR_10, sizeof(VAR_8) - VAR_10,
"User-Agent: %s\r\n", LIBAVFORMAT_IDENT); if (!has_header(s->VAR_8, "\r\nAccept: "))
VAR_10 += av_strlcpy(VAR_8 + VAR_10, "Accept: *
av_strlcpy(VAR_8+VAR_10, s->VAR_8, sizeof(VAR_8)-VAR_10); snprintf(s->buffer, sizeof(s->buffer),
"%s %s HTTP/1.1\r\n"
"%s"
"%s"
"%s"
"\r\n",
VAR_5 ? "POST" : "GET",
VAR_1,
VAR_5 && s->is_chunked ? "Transfer-Encoding: chunked\r\n" : "",
VAR_8,
VAR_9 ? VAR_9 : ""); av_freep(&VAR_9); if (http_write(VAR_0, s->buffer, strlen(s->buffer)) < 0)
return AVERROR(EIO); s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->off = 0; s->filesize = -1; if (VAR_5) { s->chunksize = 0; s->http_code = 200; return 0; } for(;;) { if (http_get_line(s, VAR_7, sizeof(VAR_7)) < 0)
return AVERROR(EIO); dprintf(NULL, "header='%s'\n", VAR_7); VAR_6 = process_line(VAR_0, VAR_7, s->line_count, VAR_4); if (VAR_6 < 0)
return VAR_6; if (VAR_6 == 0)
break; s->line_count++; } return (off == s->off) ? 0 : -1; }