static int process_line(URLContext *h, char *line, int line_count,

                        int *new_location)

{

    HTTPContext *s = h->priv_data;

    char *tag, *p, *end;



    

    if (line[0] == '\0')

        return 0;



    p = line;

    if (line_count == 0) {

        while (!isspace(*p) && *p != '\0')

            p++;

        while (isspace(*p))

            p++;

        s->http_code = strtol(p, &end, 10);



        av_dlog(NULL, "http_code=%d\n", s->http_code);



        



        if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401) {

            end += strspn(end, SPACE_CHARS);

            av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n",

                   s->http_code, end);

            return -1;

        }

    } else {

        while (*p != '\0' && *p != ':')

            p++;

        if (*p != ':')

            return 1;



        *p = '\0';

        tag = line;

        p++;

        while (isspace(*p))

            p++;

        if (!av_strcasecmp(tag, "Location")) {

            strcpy(s->location, p);

            *new_location = 1;

        } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {

            s->filesize = atoll(p);

        } else if (!av_strcasecmp (tag, "Content-Range")) {

            

            const char *slash;

            if (!strncmp (p, "bytes ", 6)) {

                p += 6;

                s->off = atoll(p);

                if ((slash = strchr(p, '/')) && strlen(slash) > 0)

                    s->filesize = atoll(slash+1);

            }

            h->is_streamed = 0; 

        } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {

            h->is_streamed = 0;

        } else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) {

            s->filesize = -1;

            s->chunksize = 0;

        } else if (!av_strcasecmp (tag, "WWW-Authenticate")) {

            ff_http_auth_handle_header(&s->auth_state, tag, p);

        } else if (!av_strcasecmp (tag, "Authentication-Info")) {

            ff_http_auth_handle_header(&s->auth_state, tag, p);

        } else if (!av_strcasecmp (tag, "Connection")) {

            if (!strcmp(p, "close"))

                s->willclose = 1;

        }

    }

    return 1;

}
