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, ch;

    char line[1024], *q;

    char *auth_b64;

    int auth_b64_len = strlen(auth)* 4 / 3 + 12;

    int64_t off = s->off;





    /* send http header */

    post = h->flags & URL_WRONLY;

    auth_b64 = av_malloc(auth_b64_len);

    av_base64_encode(auth_b64, auth_b64_len, auth, strlen(auth));

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

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

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

             "Accept: */*\r\n"

             "Range: bytes=%"PRId64"-\r\n"

             "Host: %s\r\n"

             "Authorization: Basic %s\r\n"

             "Connection: close\r\n"

             "\r\n",

             post ? "POST" : "GET",

             path,

             LIBAVFORMAT_IDENT,

             s->off,

             hoststr,

             auth_b64);



    av_freep(&auth_b64);

    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) {

        return 0;

    }



    /* wait for header */

    q = line;

    for(;;) {

        ch = http_getc(s);

        if (ch < 0)

            return AVERROR(EIO);

        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(h, line, s->line_count, new_location);

            if (err < 0)

                return err;

            if (err == 0)

                break;

            s->line_count++;

            q = line;

        } else {

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

                *q++ = ch;

        }

    }



    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, ch;

    char line[1024], *q;

    char *auth_b64;

    int auth_b64_len = strlen(auth)* 4 / 3 + 12;

    int64_t off = s->off;





    

    post = h->flags & URL_WRONLY;

    auth_b64 = av_malloc(auth_b64_len);

    av_base64_encode(auth_b64, auth_b64_len, auth, strlen(auth));

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

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

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

             "Accept: *



































    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->off = 0;

    s->filesize = -1;

    if (post) {

        return 0;

    }



    

    q = line;

    for(;;) {

        ch = http_getc(s);

        if (ch < 0)

            return AVERROR(EIO);

        if (ch == '\n') {

            

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

                q--;

            *q = '\0';

#ifdef DEBUG

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

#endif

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

            if (err < 0)

                return err;

            if (err == 0)

                break;

            s->line_count++;

            q = line;

        } else {

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

                *q++ = ch;

        }

    }



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

}

    int auth_b64_len = strlen(auth)* 4 / 3 + 12;
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, VAR_7;

    char VAR_8[1024], *VAR_9;

    char *VAR_10;

    int VAR_11 = strlen(VAR_3)* 4 / 3 + 12;

    int64_t off = s->off;





    

    VAR_5 = VAR_0->flags & URL_WRONLY;

    VAR_10 = av_malloc(VAR_11);

    av_base64_encode(VAR_10, VAR_11, VAR_3, strlen(VAR_3));

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

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

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

             "Accept: *



































    s->buf_ptr = s->buffer;

    s->buf_end = s->buffer;

    s->line_count = 0;

    s->off = 0;

    s->filesize = -1;

    if (VAR_5) {

        return 0;

    }



    

    VAR_9 = VAR_8;

    for(;;) {

        VAR_7 = http_getc(s);

        if (VAR_7 < 0)

            return AVERROR(EIO);

        if (VAR_7 == '\n') {

            

            if (VAR_9 > VAR_8 && VAR_9[-1] == '\r')

                VAR_9--;

            *VAR_9 = '\0';

#ifdef DEBUG

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

#endif

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

            if (VAR_6 < 0)

                return VAR_6;

            if (VAR_6 == 0)

                break;

            s->line_count++;

            VAR_9 = VAR_8;

        } else {

            if ((VAR_9 - VAR_8) < sizeof(VAR_8) - 1)

                *VAR_9++ = VAR_7;

        }

    }



    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, VAR_7; char VAR_8[1024], *VAR_9; char *VAR_10; int VAR_11 = strlen(VAR_3)* 4 / 3 + 12; int64_t off = s->off; VAR_5 = VAR_0->flags & URL_WRONLY; VAR_10 = av_malloc(VAR_11); av_base64_encode(VAR_10, VAR_11, VAR_3, strlen(VAR_3)); snprintf(s->buffer, sizeof(s->buffer),
"%s %s HTTP/1.1\r\n"
"User-Agent: %s\r\n"
"Accept: *
s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->off = 0; s->filesize = -1; if (VAR_5) { return 0; } VAR_9 = VAR_8; for(;;) { VAR_7 = http_getc(s); if (VAR_7 < 0)
return AVERROR(EIO); if (VAR_7 == '\n') { if (VAR_9 > VAR_8 && VAR_9[-1] == '\r')
VAR_9--; *VAR_9 = '\0'; #ifdef DEBUG
printf("header='%s'\n", VAR_8); #endif
VAR_6 = process_line(VAR_0, VAR_8, s->line_count, VAR_4); if (VAR_6 < 0)
return VAR_6; if (VAR_6 == 0)
break; s->line_count++; VAR_9 = VAR_8; } else { if ((VAR_9 - VAR_8) < sizeof(VAR_8) - 1)
*VAR_9++ = VAR_7; } } return (off == s->off) ? 0 : -1; }