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

Function http_read

libavformat/http.c:316–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314
315
316static int http_read(URLContext *h, uint8_t *buf, int size)
317{
318 HTTPContext *s = h->priv_data;
319 int len;
320
321 if (s->chunksize >= 0) {
322 if (!s->chunksize) {
323 char line[32];
324
325 for(;;) {
326 do {
327 if (http_get_line(s, line, sizeof(line)) < 0)
328 return AVERROR(EIO);
329 } while (!*line); /* skip CR LF from last chunk */
330
331 s->chunksize = strtoll(line, NULL, 16);
332
333 dprintf(NULL, "Chunked encoding data size: %"PRId64"'\n", s->chunksize);
334
335 if (!s->chunksize)
336 return 0;
337 break;
338 }
339 }
340 size = FFMIN(size, s->chunksize);
341 }
342 /* read bytes from input buffer first */
343 len = s->buf_end - s->buf_ptr;
344 if (len > 0) {
345 if (len > size)
346 len = size;
347 memcpy(buf, s->buf_ptr, len);
348 s->buf_ptr += len;
349 } else {
350 len = url_read(s->hd, buf, size);
351 }
352 if (len > 0) {
353 s->off += len;
354 if (s->chunksize > 0)
355 s->chunksize -= len;
356 }
357 return len;
358}
359
360/* used only when posting data */
361static int http_write(URLContext *h, uint8_t *buf, int size)

Callers

nothing calls this directly

Calls 2

http_get_lineFunction · 0.85
url_readFunction · 0.85

Tested by

no test coverage detected