MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / process_line

Function process_line

libavformat/http.c:187–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static int process_line(URLContext *h, char *line, int line_count,
188 int *new_location)
189{
190 HTTPContext *s = h->priv_data;
191 char *tag, *p;
192
193 /* end of header */
194 if (line[0] == '\0')
195 return 0;
196
197 p = line;
198 if (line_count == 0) {
199 while (!isspace(*p) && *p != '\0')
200 p++;
201 while (isspace(*p))
202 p++;
203 s->http_code = strtol(p, NULL, 10);
204
205 dprintf(NULL, "http_code=%d\n", s->http_code);
206
207 /* error codes are 4xx and 5xx, but regard 401 as a success, so we
208 * don't abort until all headers have been parsed. */
209 if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401)
210 return -1;
211 } else {
212 while (*p != '\0' && *p != ':')
213 p++;
214 if (*p != ':')
215 return 1;
216
217 *p = '\0';
218 tag = line;
219 p++;
220 while (isspace(*p))
221 p++;
222 if (!strcmp(tag, "Location")) {
223 strcpy(s->location, p);
224 *new_location = 1;
225 } else if (!strcmp (tag, "Content-Length") && s->filesize == -1) {
226 s->filesize = atoll(p);
227 } else if (!strcmp (tag, "Content-Range")) {
228 /* "bytes $from-$to/$document_size" */
229 const char *slash;
230 if (!strncmp (p, "bytes ", 6)) {
231 p += 6;
232 s->off = atoll(p);
233 if ((slash = strchr(p, '/')) && strlen(slash) > 0)
234 s->filesize = atoll(slash+1);
235 }
236 h->is_streamed = 0; /* we _can_ in fact seek */
237 } else if (!strcmp (tag, "Transfer-Encoding") && !strncasecmp(p, "chunked", 7)) {
238 s->filesize = -1;
239 s->chunksize = 0;
240 } else if (!strcmp (tag, "WWW-Authenticate")) {
241 ff_http_auth_handle_header(&s->auth_state, tag, p);
242 } else if (!strcmp (tag, "Authentication-Info")) {
243 ff_http_auth_handle_header(&s->auth_state, tag, p);
244 }

Callers 1

http_connectFunction · 0.85

Calls 1

Tested by

no test coverage detected