OLD | NEW |
1 /* | 1 /* |
2 * HTTP protocol for ffmpeg client | 2 * HTTP protocol for ffmpeg client |
3 * Copyright (c) 2000, 2001 Fabrice Bellard | 3 * Copyright (c) 2000, 2001 Fabrice Bellard |
4 * | 4 * |
5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
6 * | 6 * |
7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 HTTPContext *s = h->priv_data; | 62 HTTPContext *s = h->priv_data; |
63 URLContext *hd = NULL; | 63 URLContext *hd = NULL; |
64 | 64 |
65 proxy_path = getenv("http_proxy"); | 65 proxy_path = getenv("http_proxy"); |
66 use_proxy = (proxy_path != NULL) && !getenv("no_proxy") && | 66 use_proxy = (proxy_path != NULL) && !getenv("no_proxy") && |
67 av_strstart(proxy_path, "http://", NULL); | 67 av_strstart(proxy_path, "http://", NULL); |
68 | 68 |
69 /* fill the dest addr */ | 69 /* fill the dest addr */ |
70 redo: | 70 redo: |
71 /* needed in any case to build the host string */ | 71 /* needed in any case to build the host string */ |
72 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, | 72 ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, |
73 path1, sizeof(path1), s->location); | 73 path1, sizeof(path1), s->location); |
74 if (port > 0) { | 74 ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL); |
75 snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port); | |
76 } else { | |
77 av_strlcpy(hoststr, hostname, sizeof(hoststr)); | |
78 } | |
79 | 75 |
80 if (use_proxy) { | 76 if (use_proxy) { |
81 url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port
, | 77 ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &p
ort, |
82 NULL, 0, proxy_path); | 78 NULL, 0, proxy_path); |
83 path = s->location; | 79 path = s->location; |
84 } else { | 80 } else { |
85 if (path1[0] == '\0') | 81 if (path1[0] == '\0') |
86 path = "/"; | 82 path = "/"; |
87 else | 83 else |
88 path = path1; | 84 path = path1; |
89 } | 85 } |
90 if (port < 0) | 86 if (port < 0) |
91 port = 80; | 87 port = 80; |
92 | 88 |
93 snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port); | 89 ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); |
94 err = url_open(&hd, buf, URL_RDWR); | 90 err = url_open(&hd, buf, URL_RDWR); |
95 if (err < 0) | 91 if (err < 0) |
96 goto fail; | 92 goto fail; |
97 | 93 |
98 s->hd = hd; | 94 s->hd = hd; |
99 if (http_connect(h, path, hoststr, auth, &location_changed) < 0) | 95 if (http_connect(h, path, hoststr, auth, &location_changed) < 0) |
100 goto fail; | 96 goto fail; |
101 if ((s->http_code == 302 || s->http_code == 303) && location_changed == 1) { | 97 if ((s->http_code == 302 || s->http_code == 303) && location_changed == 1) { |
102 /* url moved, get next */ | 98 /* url moved, get next */ |
103 url_close(hd); | 99 url_close(hd); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 430 |
435 URLProtocol http_protocol = { | 431 URLProtocol http_protocol = { |
436 "http", | 432 "http", |
437 http_open, | 433 http_open, |
438 http_read, | 434 http_read, |
439 http_write, | 435 http_write, |
440 http_seek, | 436 http_seek, |
441 http_close, | 437 http_close, |
442 .url_get_file_handle = http_get_file_handle, | 438 .url_get_file_handle = http_get_file_handle, |
443 }; | 439 }; |
OLD | NEW |