]> git.sesse.net Git - ffmpeg/blob - libavformat/http.c
5941925118864ca5f3e54fc06d8a540247da582b
[ffmpeg] / libavformat / http.c
1 /*
2  * HTTP protocol for avconv client
3  * Copyright (c) 2000, 2001 Fabrice Bellard
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #include "libavutil/avstring.h"
23 #include "avformat.h"
24 #include <unistd.h>
25 #include "internal.h"
26 #include "network.h"
27 #include "http.h"
28 #include "os_support.h"
29 #include "httpauth.h"
30 #include "url.h"
31 #include "libavutil/opt.h"
32
33 /* XXX: POST protocol is not completely implemented because avconv uses
34    only a subset of it. */
35
36 /* used for protocol handling */
37 #define BUFFER_SIZE 1024
38 #define MAX_REDIRECTS 8
39
40 typedef struct {
41     const AVClass *class;
42     URLContext *hd;
43     unsigned char buffer[BUFFER_SIZE], *buf_ptr, *buf_end;
44     int line_count;
45     int http_code;
46     int64_t chunksize;      /**< Used if "Transfer-Encoding: chunked" otherwise -1. */
47     int64_t off, filesize;
48     char location[MAX_URL_SIZE];
49     HTTPAuthState auth_state;
50     HTTPAuthState proxy_auth_state;
51     char *headers;
52     int willclose;          /**< Set if the server correctly handles Connection: close and will close the connection after feeding us the content. */
53     int chunked_post;
54 } HTTPContext;
55
56 #define OFFSET(x) offsetof(HTTPContext, x)
57 #define D AV_OPT_FLAG_DECODING_PARAM
58 #define E AV_OPT_FLAG_ENCODING_PARAM
59 static const AVOption options[] = {
60 {"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.dbl = 1}, 0, 1, E },
61 {"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
62 {NULL}
63 };
64 #define HTTP_CLASS(flavor)\
65 static const AVClass flavor ## _context_class = {\
66     .class_name     = #flavor,\
67     .item_name      = av_default_item_name,\
68     .option         = options,\
69     .version        = LIBAVUTIL_VERSION_INT,\
70 };
71
72 HTTP_CLASS(http);
73 HTTP_CLASS(https);
74
75 static int http_connect(URLContext *h, const char *path, const char *local_path,
76                         const char *hoststr, const char *auth,
77                         const char *proxyauth, int *new_location);
78
79 void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
80 {
81     memcpy(&((HTTPContext*)dest->priv_data)->auth_state,
82            &((HTTPContext*)src->priv_data)->auth_state, sizeof(HTTPAuthState));
83     memcpy(&((HTTPContext*)dest->priv_data)->proxy_auth_state,
84            &((HTTPContext*)src->priv_data)->proxy_auth_state,
85            sizeof(HTTPAuthState));
86 }
87
88 /* return non zero if error */
89 static int http_open_cnx(URLContext *h)
90 {
91     const char *path, *proxy_path, *lower_proto = "tcp", *local_path;
92     char hostname[1024], hoststr[1024], proto[10];
93     char auth[1024], proxyauth[1024];
94     char path1[1024];
95     char buf[1024], urlbuf[1024];
96     int port, use_proxy, err, location_changed = 0, redirects = 0;
97     HTTPAuthType cur_auth_type, cur_proxy_auth_type;
98     HTTPContext *s = h->priv_data;
99     URLContext *hd = NULL;
100
101     proxy_path = getenv("http_proxy");
102     use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
103         av_strstart(proxy_path, "http://", NULL);
104
105     /* fill the dest addr */
106  redo:
107     /* needed in any case to build the host string */
108     av_url_split(proto, sizeof(proto), auth, sizeof(auth),
109                  hostname, sizeof(hostname), &port,
110                  path1, sizeof(path1), s->location);
111     ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
112
113     if (path1[0] == '\0')
114         path = "/";
115     else
116         path = path1;
117     local_path = path;
118     if (use_proxy) {
119         /* Reassemble the request URL without auth string - we don't
120          * want to leak the auth to the proxy. */
121         ff_url_join(urlbuf, sizeof(urlbuf), proto, NULL, hostname, port, "%s",
122                     path1);
123         path = urlbuf;
124         av_url_split(NULL, 0, proxyauth, sizeof(proxyauth),
125                      hostname, sizeof(hostname), &port, NULL, 0, proxy_path);
126     }
127     if (!strcmp(proto, "https")) {
128         lower_proto = "tls";
129         if (port < 0)
130             port = 443;
131     }
132     if (port < 0)
133         port = 80;
134
135     ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
136     err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE,
137                      &h->interrupt_callback, NULL);
138     if (err < 0)
139         goto fail;
140
141     s->hd = hd;
142     cur_auth_type = s->auth_state.auth_type;
143     cur_proxy_auth_type = s->auth_state.auth_type;
144     if (http_connect(h, path, local_path, hoststr, auth, proxyauth, &location_changed) < 0)
145         goto fail;
146     if (s->http_code == 401) {
147         if (cur_auth_type == HTTP_AUTH_NONE && s->auth_state.auth_type != HTTP_AUTH_NONE) {
148             ffurl_close(hd);
149             goto redo;
150         } else
151             goto fail;
152     }
153     if (s->http_code == 407) {
154         if (cur_proxy_auth_type == HTTP_AUTH_NONE &&
155             s->proxy_auth_state.auth_type != HTTP_AUTH_NONE) {
156             ffurl_close(hd);
157             goto redo;
158         } else
159             goto fail;
160     }
161     if ((s->http_code == 301 || s->http_code == 302 || s->http_code == 303 || s->http_code == 307)
162         && location_changed == 1) {
163         /* url moved, get next */
164         ffurl_close(hd);
165         if (redirects++ >= MAX_REDIRECTS)
166             return AVERROR(EIO);
167         location_changed = 0;
168         goto redo;
169     }
170     return 0;
171  fail:
172     if (hd)
173         ffurl_close(hd);
174     s->hd = NULL;
175     return AVERROR(EIO);
176 }
177
178 static int http_open(URLContext *h, const char *uri, int flags)
179 {
180     HTTPContext *s = h->priv_data;
181
182     h->is_streamed = 1;
183
184     s->filesize = -1;
185     av_strlcpy(s->location, uri, sizeof(s->location));
186
187     if (s->headers) {
188         int len = strlen(s->headers);
189         if (len < 2 || strcmp("\r\n", s->headers + len - 2))
190             av_log(h, AV_LOG_WARNING, "No trailing CRLF found in HTTP header.\n");
191     }
192
193     return http_open_cnx(h);
194 }
195 static int http_getc(HTTPContext *s)
196 {
197     int len;
198     if (s->buf_ptr >= s->buf_end) {
199         len = ffurl_read(s->hd, s->buffer, BUFFER_SIZE);
200         if (len < 0) {
201             return AVERROR(EIO);
202         } else if (len == 0) {
203             return -1;
204         } else {
205             s->buf_ptr = s->buffer;
206             s->buf_end = s->buffer + len;
207         }
208     }
209     return *s->buf_ptr++;
210 }
211
212 static int http_get_line(HTTPContext *s, char *line, int line_size)
213 {
214     int ch;
215     char *q;
216
217     q = line;
218     for(;;) {
219         ch = http_getc(s);
220         if (ch < 0)
221             return AVERROR(EIO);
222         if (ch == '\n') {
223             /* process line */
224             if (q > line && q[-1] == '\r')
225                 q--;
226             *q = '\0';
227
228             return 0;
229         } else {
230             if ((q - line) < line_size - 1)
231                 *q++ = ch;
232         }
233     }
234 }
235
236 static int process_line(URLContext *h, char *line, int line_count,
237                         int *new_location)
238 {
239     HTTPContext *s = h->priv_data;
240     char *tag, *p, *end;
241
242     /* end of header */
243     if (line[0] == '\0')
244         return 0;
245
246     p = line;
247     if (line_count == 0) {
248         while (!isspace(*p) && *p != '\0')
249             p++;
250         while (isspace(*p))
251             p++;
252         s->http_code = strtol(p, &end, 10);
253
254         av_dlog(NULL, "http_code=%d\n", s->http_code);
255
256         /* error codes are 4xx and 5xx, but regard 401 as a success, so we
257          * don't abort until all headers have been parsed. */
258         if (s->http_code >= 400 && s->http_code < 600 && (s->http_code != 401
259             || s->auth_state.auth_type != HTTP_AUTH_NONE) &&
260             (s->http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) {
261             end += strspn(end, SPACE_CHARS);
262             av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n",
263                    s->http_code, end);
264             return -1;
265         }
266     } else {
267         while (*p != '\0' && *p != ':')
268             p++;
269         if (*p != ':')
270             return 1;
271
272         *p = '\0';
273         tag = line;
274         p++;
275         while (isspace(*p))
276             p++;
277         if (!av_strcasecmp(tag, "Location")) {
278             strcpy(s->location, p);
279             *new_location = 1;
280         } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
281             s->filesize = atoll(p);
282         } else if (!av_strcasecmp (tag, "Content-Range")) {
283             /* "bytes $from-$to/$document_size" */
284             const char *slash;
285             if (!strncmp (p, "bytes ", 6)) {
286                 p += 6;
287                 s->off = atoll(p);
288                 if ((slash = strchr(p, '/')) && strlen(slash) > 0)
289                     s->filesize = atoll(slash+1);
290             }
291             h->is_streamed = 0; /* we _can_ in fact seek */
292         } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {
293             h->is_streamed = 0;
294         } else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) {
295             s->filesize = -1;
296             s->chunksize = 0;
297         } else if (!av_strcasecmp (tag, "WWW-Authenticate")) {
298             ff_http_auth_handle_header(&s->auth_state, tag, p);
299         } else if (!av_strcasecmp (tag, "Authentication-Info")) {
300             ff_http_auth_handle_header(&s->auth_state, tag, p);
301         } else if (!av_strcasecmp (tag, "Proxy-Authenticate")) {
302             ff_http_auth_handle_header(&s->proxy_auth_state, tag, p);
303         } else if (!av_strcasecmp (tag, "Connection")) {
304             if (!strcmp(p, "close"))
305                 s->willclose = 1;
306         }
307     }
308     return 1;
309 }
310
311 static inline int has_header(const char *str, const char *header)
312 {
313     /* header + 2 to skip over CRLF prefix. (make sure you have one!) */
314     if (!str)
315         return 0;
316     return av_stristart(str, header + 2, NULL) || av_stristr(str, header);
317 }
318
319 static int http_connect(URLContext *h, const char *path, const char *local_path,
320                         const char *hoststr, const char *auth,
321                         const char *proxyauth, int *new_location)
322 {
323     HTTPContext *s = h->priv_data;
324     int post, err;
325     char line[1024];
326     char headers[1024] = "";
327     char *authstr = NULL, *proxyauthstr = NULL;
328     int64_t off = s->off;
329     int len = 0;
330     const char *method;
331
332
333     /* send http header */
334     post = h->flags & AVIO_FLAG_WRITE;
335     method = post ? "POST" : "GET";
336     authstr = ff_http_auth_create_response(&s->auth_state, auth, local_path,
337                                            method);
338     proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth,
339                                                 local_path, method);
340
341     /* set default headers if needed */
342     if (!has_header(s->headers, "\r\nUser-Agent: "))
343        len += av_strlcatf(headers + len, sizeof(headers) - len,
344                           "User-Agent: %s\r\n", LIBAVFORMAT_IDENT);
345     if (!has_header(s->headers, "\r\nAccept: "))
346         len += av_strlcpy(headers + len, "Accept: */*\r\n",
347                           sizeof(headers) - len);
348     if (!has_header(s->headers, "\r\nRange: ") && !post)
349         len += av_strlcatf(headers + len, sizeof(headers) - len,
350                            "Range: bytes=%"PRId64"-\r\n", s->off);
351     if (!has_header(s->headers, "\r\nConnection: "))
352         len += av_strlcpy(headers + len, "Connection: close\r\n",
353                           sizeof(headers)-len);
354     if (!has_header(s->headers, "\r\nHost: "))
355         len += av_strlcatf(headers + len, sizeof(headers) - len,
356                            "Host: %s\r\n", hoststr);
357
358     /* now add in custom headers */
359     if (s->headers)
360         av_strlcpy(headers + len, s->headers, sizeof(headers) - len);
361
362     snprintf(s->buffer, sizeof(s->buffer),
363              "%s %s HTTP/1.1\r\n"
364              "%s"
365              "%s"
366              "%s"
367              "%s%s"
368              "\r\n",
369              method,
370              path,
371              post && s->chunked_post ? "Transfer-Encoding: chunked\r\n" : "",
372              headers,
373              authstr ? authstr : "",
374              proxyauthstr ? "Proxy-" : "", proxyauthstr ? proxyauthstr : "");
375
376     av_freep(&authstr);
377     av_freep(&proxyauthstr);
378     if (ffurl_write(s->hd, s->buffer, strlen(s->buffer)) < 0)
379         return AVERROR(EIO);
380
381     /* init input buffer */
382     s->buf_ptr = s->buffer;
383     s->buf_end = s->buffer;
384     s->line_count = 0;
385     s->off = 0;
386     s->filesize = -1;
387     s->willclose = 0;
388     if (post) {
389         /* Pretend that it did work. We didn't read any header yet, since
390          * we've still to send the POST data, but the code calling this
391          * function will check http_code after we return. */
392         s->http_code = 200;
393         return 0;
394     }
395     s->chunksize = -1;
396
397     /* wait for header */
398     for(;;) {
399         if (http_get_line(s, line, sizeof(line)) < 0)
400             return AVERROR(EIO);
401
402         av_dlog(NULL, "header='%s'\n", line);
403
404         err = process_line(h, line, s->line_count, new_location);
405         if (err < 0)
406             return err;
407         if (err == 0)
408             break;
409         s->line_count++;
410     }
411
412     return (off == s->off) ? 0 : -1;
413 }
414
415
416 static int http_buf_read(URLContext *h, uint8_t *buf, int size)
417 {
418     HTTPContext *s = h->priv_data;
419     int len;
420     /* read bytes from input buffer first */
421     len = s->buf_end - s->buf_ptr;
422     if (len > 0) {
423         if (len > size)
424             len = size;
425         memcpy(buf, s->buf_ptr, len);
426         s->buf_ptr += len;
427     } else {
428         if (!s->willclose && s->filesize >= 0 && s->off >= s->filesize)
429             return AVERROR_EOF;
430         len = ffurl_read(s->hd, buf, size);
431     }
432     if (len > 0) {
433         s->off += len;
434         if (s->chunksize > 0)
435             s->chunksize -= len;
436     }
437     return len;
438 }
439
440 static int http_read(URLContext *h, uint8_t *buf, int size)
441 {
442     HTTPContext *s = h->priv_data;
443
444     if (s->chunksize >= 0) {
445         if (!s->chunksize) {
446             char line[32];
447
448             for(;;) {
449                 do {
450                     if (http_get_line(s, line, sizeof(line)) < 0)
451                         return AVERROR(EIO);
452                 } while (!*line);    /* skip CR LF from last chunk */
453
454                 s->chunksize = strtoll(line, NULL, 16);
455
456                 av_dlog(NULL, "Chunked encoding data size: %"PRId64"'\n", s->chunksize);
457
458                 if (!s->chunksize)
459                     return 0;
460                 break;
461             }
462         }
463         size = FFMIN(size, s->chunksize);
464     }
465     return http_buf_read(h, buf, size);
466 }
467
468 /* used only when posting data */
469 static int http_write(URLContext *h, const uint8_t *buf, int size)
470 {
471     char temp[11] = "";  /* 32-bit hex + CRLF + nul */
472     int ret;
473     char crlf[] = "\r\n";
474     HTTPContext *s = h->priv_data;
475
476     if (!s->chunked_post) {
477         /* non-chunked data is sent without any special encoding */
478         return ffurl_write(s->hd, buf, size);
479     }
480
481     /* silently ignore zero-size data since chunk encoding that would
482      * signal EOF */
483     if (size > 0) {
484         /* upload data using chunked encoding */
485         snprintf(temp, sizeof(temp), "%x\r\n", size);
486
487         if ((ret = ffurl_write(s->hd, temp, strlen(temp))) < 0 ||
488             (ret = ffurl_write(s->hd, buf, size)) < 0 ||
489             (ret = ffurl_write(s->hd, crlf, sizeof(crlf) - 1)) < 0)
490             return ret;
491     }
492     return size;
493 }
494
495 static int http_close(URLContext *h)
496 {
497     int ret = 0;
498     char footer[] = "0\r\n\r\n";
499     HTTPContext *s = h->priv_data;
500
501     /* signal end of chunked encoding if used */
502     if ((h->flags & AVIO_FLAG_WRITE) && s->chunked_post) {
503         ret = ffurl_write(s->hd, footer, sizeof(footer) - 1);
504         ret = ret > 0 ? 0 : ret;
505     }
506
507     if (s->hd)
508         ffurl_close(s->hd);
509     return ret;
510 }
511
512 static int64_t http_seek(URLContext *h, int64_t off, int whence)
513 {
514     HTTPContext *s = h->priv_data;
515     URLContext *old_hd = s->hd;
516     int64_t old_off = s->off;
517     uint8_t old_buf[BUFFER_SIZE];
518     int old_buf_size;
519
520     if (whence == AVSEEK_SIZE)
521         return s->filesize;
522     else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed)
523         return -1;
524
525     /* we save the old context in case the seek fails */
526     old_buf_size = s->buf_end - s->buf_ptr;
527     memcpy(old_buf, s->buf_ptr, old_buf_size);
528     s->hd = NULL;
529     if (whence == SEEK_CUR)
530         off += s->off;
531     else if (whence == SEEK_END)
532         off += s->filesize;
533     s->off = off;
534
535     /* if it fails, continue on old connection */
536     if (http_open_cnx(h) < 0) {
537         memcpy(s->buffer, old_buf, old_buf_size);
538         s->buf_ptr = s->buffer;
539         s->buf_end = s->buffer + old_buf_size;
540         s->hd = old_hd;
541         s->off = old_off;
542         return -1;
543     }
544     ffurl_close(old_hd);
545     return off;
546 }
547
548 static int
549 http_get_file_handle(URLContext *h)
550 {
551     HTTPContext *s = h->priv_data;
552     return ffurl_get_file_handle(s->hd);
553 }
554
555 #if CONFIG_HTTP_PROTOCOL
556 URLProtocol ff_http_protocol = {
557     .name                = "http",
558     .url_open            = http_open,
559     .url_read            = http_read,
560     .url_write           = http_write,
561     .url_seek            = http_seek,
562     .url_close           = http_close,
563     .url_get_file_handle = http_get_file_handle,
564     .priv_data_size      = sizeof(HTTPContext),
565     .priv_data_class     = &http_context_class,
566 };
567 #endif
568 #if CONFIG_HTTPS_PROTOCOL
569 URLProtocol ff_https_protocol = {
570     .name                = "https",
571     .url_open            = http_open,
572     .url_read            = http_read,
573     .url_write           = http_write,
574     .url_seek            = http_seek,
575     .url_close           = http_close,
576     .url_get_file_handle = http_get_file_handle,
577     .priv_data_size      = sizeof(HTTPContext),
578     .priv_data_class     = &https_context_class,
579 };
580 #endif
581
582 #if CONFIG_HTTPPROXY_PROTOCOL
583 static int http_proxy_close(URLContext *h)
584 {
585     HTTPContext *s = h->priv_data;
586     if (s->hd)
587         ffurl_close(s->hd);
588     return 0;
589 }
590
591 static int http_proxy_open(URLContext *h, const char *uri, int flags)
592 {
593     HTTPContext *s = h->priv_data;
594     char hostname[1024], hoststr[1024];
595     char auth[1024], pathbuf[1024], *path;
596     char line[1024], lower_url[100];
597     int port, ret = 0;
598     HTTPAuthType cur_auth_type;
599     char *authstr;
600
601     h->is_streamed = 1;
602
603     av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
604                  pathbuf, sizeof(pathbuf), uri);
605     ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
606     path = pathbuf;
607     if (*path == '/')
608         path++;
609
610     ff_url_join(lower_url, sizeof(lower_url), "tcp", NULL, hostname, port,
611                 NULL);
612 redo:
613     ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE,
614                      &h->interrupt_callback, NULL);
615     if (ret < 0)
616         return ret;
617
618     authstr = ff_http_auth_create_response(&s->proxy_auth_state, auth,
619                                            path, "CONNECT");
620     snprintf(s->buffer, sizeof(s->buffer),
621              "CONNECT %s HTTP/1.1\r\n"
622              "Host: %s\r\n"
623              "Connection: close\r\n"
624              "%s%s"
625              "\r\n",
626              path,
627              hoststr,
628              authstr ? "Proxy-" : "", authstr ? authstr : "");
629     av_freep(&authstr);
630
631     if ((ret = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0)
632         goto fail;
633
634     s->buf_ptr = s->buffer;
635     s->buf_end = s->buffer;
636     s->line_count = 0;
637     s->filesize = -1;
638     cur_auth_type = s->proxy_auth_state.auth_type;
639
640     for (;;) {
641         int new_loc;
642         // Note: This uses buffering, potentially reading more than the
643         // HTTP header. If tunneling a protocol where the server starts
644         // the conversation, we might buffer part of that here, too.
645         // Reading that requires using the proper ffurl_read() function
646         // on this URLContext, not using the fd directly (as the tls
647         // protocol does). This shouldn't be an issue for tls though,
648         // since the client starts the conversation there, so there
649         // is no extra data that we might buffer up here.
650         if (http_get_line(s, line, sizeof(line)) < 0) {
651             ret = AVERROR(EIO);
652             goto fail;
653         }
654
655         av_dlog(h, "header='%s'\n", line);
656
657         ret = process_line(h, line, s->line_count, &new_loc);
658         if (ret < 0)
659             goto fail;
660         if (ret == 0)
661             break;
662         s->line_count++;
663     }
664     if (s->http_code == 407 && cur_auth_type == HTTP_AUTH_NONE &&
665         s->proxy_auth_state.auth_type != HTTP_AUTH_NONE) {
666         ffurl_close(s->hd);
667         s->hd = NULL;
668         goto redo;
669     }
670
671     if (s->http_code < 400)
672         return 0;
673     ret = AVERROR(EIO);
674
675 fail:
676     http_proxy_close(h);
677     return ret;
678 }
679
680 static int http_proxy_write(URLContext *h, const uint8_t *buf, int size)
681 {
682     HTTPContext *s = h->priv_data;
683     return ffurl_write(s->hd, buf, size);
684 }
685
686 URLProtocol ff_httpproxy_protocol = {
687     .name                = "httpproxy",
688     .url_open            = http_proxy_open,
689     .url_read            = http_buf_read,
690     .url_write           = http_proxy_write,
691     .url_close           = http_proxy_close,
692     .url_get_file_handle = http_get_file_handle,
693     .priv_data_size      = sizeof(HTTPContext),
694 };
695 #endif