Mercurial > libavformat.hg
annotate http.c @ 5839:446f49e8942a libavformat
riff: don't pad extradata when writing ASF.
Patch by Anton Khirnov mirror(moc liamg saksyw)
author | benoit |
---|---|
date | Mon, 15 Mar 2010 08:49:02 +0000 |
parents | d605f589f0be |
children | 61062082488b |
rev | line source |
---|---|
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
1 /* |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
2 * HTTP protocol for ffmpeg client |
4251
77e0c7511d41
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
3973
diff
changeset
|
3 * Copyright (c) 2000, 2001 Fabrice Bellard |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
4 * |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
6 * |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
11 * |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
16 * |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
20 */ |
3286 | 21 |
22 #include "libavutil/base64.h" | |
23 #include "libavutil/avstring.h" | |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
24 #include "avformat.h" |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
25 #include <unistd.h> |
5059
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
26 #include <strings.h> |
5837
d605f589f0be
move ff_url_split() and ff_url_join() declarations to internal.h
aurel
parents:
5776
diff
changeset
|
27 #include "internal.h" |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
28 #include "network.h" |
2774
477419a721a3
os_support.h is also needed for usleep and lseek on MinGW.
ramiro
parents:
2274
diff
changeset
|
29 #include "os_support.h" |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
30 |
1986 | 31 /* XXX: POST protocol is not completely implemented because ffmpeg uses |
32 only a subset of it. */ | |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
33 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
34 /* used for protocol handling */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
35 #define BUFFER_SIZE 1024 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
36 #define URL_SIZE 4096 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
37 #define MAX_REDIRECTS 8 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
38 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
39 typedef struct { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
40 URLContext *hd; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
41 unsigned char buffer[BUFFER_SIZE], *buf_ptr, *buf_end; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
42 int line_count; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
43 int http_code; |
5059
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
44 int64_t chunksize; /**< Used if "Transfer-Encoding: chunked" otherwise -1. */ |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3286
diff
changeset
|
45 int64_t off, filesize; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
46 char location[URL_SIZE]; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
47 } HTTPContext; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
48 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
49 static int http_connect(URLContext *h, const char *path, const char *hoststr, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
50 const char *auth, int *new_location); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
51 static int http_write(URLContext *h, uint8_t *buf, int size); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
52 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
53 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
54 /* return non zero if error */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
55 static int http_open_cnx(URLContext *h) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
56 { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
57 const char *path, *proxy_path; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
58 char hostname[1024], hoststr[1024]; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
59 char auth[1024]; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
60 char path1[1024]; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
61 char buf[1024]; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
62 int port, use_proxy, err, location_changed = 0, redirects = 0; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
63 HTTPContext *s = h->priv_data; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
64 URLContext *hd = NULL; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
65 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
66 proxy_path = getenv("http_proxy"); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
67 use_proxy = (proxy_path != NULL) && !getenv("no_proxy") && |
2193
5ce5fad0dfac
replace the uses of old string functions that Reimar missed
mru
parents:
2189
diff
changeset
|
68 av_strstart(proxy_path, "http://", NULL); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
69 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
70 /* fill the dest addr */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
71 redo: |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
72 /* needed in any case to build the host string */ |
5775 | 73 ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, |
5776 | 74 path1, sizeof(path1), s->location); |
5756
7c7fe75728dd
Use ff_url_join for assembling URLs, instead of snprintf
mstorsjo
parents:
5544
diff
changeset
|
75 ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
76 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
77 if (use_proxy) { |
5775 | 78 ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, |
5776 | 79 NULL, 0, proxy_path); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
80 path = s->location; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
81 } else { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
82 if (path1[0] == '\0') |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
83 path = "/"; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
84 else |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
85 path = path1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
86 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
87 if (port < 0) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
88 port = 80; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
89 |
5756
7c7fe75728dd
Use ff_url_join for assembling URLs, instead of snprintf
mstorsjo
parents:
5544
diff
changeset
|
90 ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
91 err = url_open(&hd, buf, URL_RDWR); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
92 if (err < 0) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
93 goto fail; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
94 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
95 s->hd = hd; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
96 if (http_connect(h, path, hoststr, auth, &location_changed) < 0) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
97 goto fail; |
1852
467a411b5d26
make HTTP MOVED messages also work in ffmpeg (302 is essentially the same as 303).
gpoirier
parents:
1822
diff
changeset
|
98 if ((s->http_code == 302 || s->http_code == 303) && location_changed == 1) { |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
99 /* url moved, get next */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
100 url_close(hd); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
101 if (redirects++ >= MAX_REDIRECTS) |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2193
diff
changeset
|
102 return AVERROR(EIO); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
103 location_changed = 0; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
104 goto redo; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
105 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
106 return 0; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
107 fail: |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
108 if (hd) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
109 url_close(hd); |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2193
diff
changeset
|
110 return AVERROR(EIO); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
111 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
112 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
113 static int http_open(URLContext *h, const char *uri, int flags) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
114 { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
115 HTTPContext *s; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
116 int ret; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
117 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
118 h->is_streamed = 1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
119 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
120 s = av_malloc(sizeof(HTTPContext)); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
121 if (!s) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
122 return AVERROR(ENOMEM); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
123 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
124 h->priv_data = s; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
125 s->filesize = -1; |
5059
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
126 s->chunksize = -1; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
127 s->off = 0; |
2193
5ce5fad0dfac
replace the uses of old string functions that Reimar missed
mru
parents:
2189
diff
changeset
|
128 av_strlcpy(s->location, uri, URL_SIZE); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
129 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
130 ret = http_open_cnx(h); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
131 if (ret != 0) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
132 av_free (s); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
133 return ret; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
134 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
135 static int http_getc(HTTPContext *s) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
136 { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
137 int len; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
138 if (s->buf_ptr >= s->buf_end) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
139 len = url_read(s->hd, s->buffer, BUFFER_SIZE); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
140 if (len < 0) { |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2193
diff
changeset
|
141 return AVERROR(EIO); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
142 } else if (len == 0) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
143 return -1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
144 } else { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
145 s->buf_ptr = s->buffer; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
146 s->buf_end = s->buffer + len; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
147 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
148 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
149 return *s->buf_ptr++; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
150 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
151 |
5007
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
152 static int http_get_line(HTTPContext *s, char *line, int line_size) |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
153 { |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
154 int ch; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
155 char *q; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
156 |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
157 q = line; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
158 for(;;) { |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
159 ch = http_getc(s); |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
160 if (ch < 0) |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
161 return AVERROR(EIO); |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
162 if (ch == '\n') { |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
163 /* process line */ |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
164 if (q > line && q[-1] == '\r') |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
165 q--; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
166 *q = '\0'; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
167 |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
168 return 0; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
169 } else { |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
170 if ((q - line) < line_size - 1) |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
171 *q++ = ch; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
172 } |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
173 } |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
174 } |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
175 |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
176 static int process_line(URLContext *h, char *line, int line_count, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
177 int *new_location) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
178 { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
179 HTTPContext *s = h->priv_data; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
180 char *tag, *p; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
181 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
182 /* end of header */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
183 if (line[0] == '\0') |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
184 return 0; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
185 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
186 p = line; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
187 if (line_count == 0) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
188 while (!isspace(*p) && *p != '\0') |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
189 p++; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
190 while (isspace(*p)) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
191 p++; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
192 s->http_code = strtol(p, NULL, 10); |
5009 | 193 |
194 dprintf(NULL, "http_code=%d\n", s->http_code); | |
195 | |
1881 | 196 /* error codes are 4xx and 5xx */ |
197 if (s->http_code >= 400 && s->http_code < 600) | |
198 return -1; | |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
199 } else { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
200 while (*p != '\0' && *p != ':') |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
201 p++; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
202 if (*p != ':') |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
203 return 1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
204 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
205 *p = '\0'; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
206 tag = line; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
207 p++; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
208 while (isspace(*p)) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
209 p++; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
210 if (!strcmp(tag, "Location")) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
211 strcpy(s->location, p); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
212 *new_location = 1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
213 } else if (!strcmp (tag, "Content-Length") && s->filesize == -1) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
214 s->filesize = atoll(p); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
215 } else if (!strcmp (tag, "Content-Range")) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
216 /* "bytes $from-$to/$document_size" */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
217 const char *slash; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
218 if (!strncmp (p, "bytes ", 6)) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
219 p += 6; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
220 s->off = atoll(p); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
221 if ((slash = strchr(p, '/')) && strlen(slash) > 0) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
222 s->filesize = atoll(slash+1); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
223 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
224 h->is_streamed = 0; /* we _can_ in fact seek */ |
5059
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
225 } else if (!strcmp (tag, "Transfer-Encoding") && !strncasecmp(p, "chunked", 7)) { |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
226 s->filesize = -1; |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
227 s->chunksize = 0; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
228 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
229 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
230 return 1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
231 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
232 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
233 static int http_connect(URLContext *h, const char *path, const char *hoststr, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
234 const char *auth, int *new_location) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
235 { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
236 HTTPContext *s = h->priv_data; |
5007
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
237 int post, err; |
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
238 char line[1024]; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
239 char *auth_b64; |
4630
e04458242c54
Reduce allocated length of the HTTP authentication request field buffer, as
rbultje
parents:
4251
diff
changeset
|
240 int auth_b64_len = (strlen(auth) + 2) / 3 * 4 + 1; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3286
diff
changeset
|
241 int64_t off = s->off; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
242 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
243 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
244 /* send http header */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
245 post = h->flags & URL_WRONLY; |
1934 | 246 auth_b64 = av_malloc(auth_b64_len); |
3001 | 247 av_base64_encode(auth_b64, auth_b64_len, auth, strlen(auth)); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
248 snprintf(s->buffer, sizeof(s->buffer), |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
249 "%s %s HTTP/1.1\r\n" |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
250 "User-Agent: %s\r\n" |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
251 "Accept: */*\r\n" |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
252 "Range: bytes=%"PRId64"-\r\n" |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
253 "Host: %s\r\n" |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
254 "Authorization: Basic %s\r\n" |
1853 | 255 "Connection: close\r\n" |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
256 "%s" |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
257 "\r\n", |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
258 post ? "POST" : "GET", |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
259 path, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
260 LIBAVFORMAT_IDENT, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
261 s->off, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
262 hoststr, |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
263 auth_b64, |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
264 post ? "Transfer-Encoding: chunked\r\n" : ""); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
265 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
266 av_freep(&auth_b64); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
267 if (http_write(h, s->buffer, strlen(s->buffer)) < 0) |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2193
diff
changeset
|
268 return AVERROR(EIO); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
269 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
270 /* init input buffer */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
271 s->buf_ptr = s->buffer; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
272 s->buf_end = s->buffer; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
273 s->line_count = 0; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
274 s->off = 0; |
1909
663139d56669
Properly initialize filesize during input buffer initialization.
diego
parents:
1881
diff
changeset
|
275 s->filesize = -1; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
276 if (post) { |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
277 /* always use chunked encoding for upload data */ |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
278 s->chunksize = 0; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
279 return 0; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
280 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
281 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
282 /* wait for header */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
283 for(;;) { |
5007
1d5f8836c8a8
Introduce http_get_line and modify http_connect to use http_get_line.
jai_menon
parents:
4640
diff
changeset
|
284 if (http_get_line(s, line, sizeof(line)) < 0) |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2193
diff
changeset
|
285 return AVERROR(EIO); |
5009 | 286 |
287 dprintf(NULL, "header='%s'\n", line); | |
288 | |
5008 | 289 err = process_line(h, line, s->line_count, new_location); |
290 if (err < 0) | |
291 return err; | |
292 if (err == 0) | |
293 break; | |
294 s->line_count++; | |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
295 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
296 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
297 return (off == s->off) ? 0 : -1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
298 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
299 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
300 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
301 static int http_read(URLContext *h, uint8_t *buf, int size) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
302 { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
303 HTTPContext *s = h->priv_data; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
304 int len; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
305 |
5059
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
306 if (s->chunksize >= 0) { |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
307 if (!s->chunksize) { |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
308 char line[32]; |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
309 |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
310 for(;;) { |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
311 do { |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
312 if (http_get_line(s, line, sizeof(line)) < 0) |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
313 return AVERROR(EIO); |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
314 } while (!*line); /* skip CR LF from last chunk */ |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
315 |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
316 s->chunksize = strtoll(line, NULL, 16); |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
317 |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
318 dprintf(NULL, "Chunked encoding data size: %"PRId64"'\n", s->chunksize); |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
319 |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
320 if (!s->chunksize) |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
321 return 0; |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
322 break; |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
323 } |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
324 } |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
325 size = FFMIN(size, s->chunksize); |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
326 } |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
327 /* read bytes from input buffer first */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
328 len = s->buf_end - s->buf_ptr; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
329 if (len > 0) { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
330 if (len > size) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
331 len = size; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
332 memcpy(buf, s->buf_ptr, len); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
333 s->buf_ptr += len; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
334 } else { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
335 len = url_read(s->hd, buf, size); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
336 } |
5059
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
337 if (len > 0) { |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
338 s->off += len; |
5059
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
339 if (s->chunksize > 0) |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
340 s->chunksize -= len; |
a5b8b8cce2dd
Add support for "chunked" data blocks. Patch by Peter Holik (peter holik at).
rbultje
parents:
5009
diff
changeset
|
341 } |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
342 return len; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
343 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
344 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
345 /* used only when posting data */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
346 static int http_write(URLContext *h, uint8_t *buf, int size) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
347 { |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
348 char temp[11]; /* 32-bit hex + CRLF + nul */ |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
349 int ret; |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
350 char crlf[] = "\r\n"; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
351 HTTPContext *s = h->priv_data; |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
352 |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
353 if (s->chunksize == -1) { |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
354 /* headers are sent without any special encoding */ |
5527 | 355 return url_write(s->hd, buf, size); |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
356 } |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
357 |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
358 /* silently ignore zero-size data since chunk encoding that would |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
359 * signal EOF */ |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
360 if (size > 0) { |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
361 /* upload data using chunked encoding */ |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
362 snprintf(temp, sizeof(temp), "%x\r\n", size); |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
363 |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
364 if ((ret = url_write(s->hd, temp, strlen(temp))) < 0 || |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
365 (ret = url_write(s->hd, buf, size)) < 0 || |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
366 (ret = url_write(s->hd, crlf, sizeof(crlf) - 1)) < 0) |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
367 return ret; |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
368 } |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
369 return size; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
370 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
371 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
372 static int http_close(URLContext *h) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
373 { |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
374 int ret = 0; |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
375 char footer[] = "0\r\n\r\n"; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
376 HTTPContext *s = h->priv_data; |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
377 |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
378 /* signal end of chunked encoding if used */ |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
379 if ((h->flags & URL_WRONLY) && s->chunksize != -1) { |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
380 ret = url_write(s->hd, footer, sizeof(footer) - 1); |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
381 ret = ret > 0 ? 0 : ret; |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
382 } |
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
383 |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
384 url_close(s->hd); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
385 av_free(s); |
5526
f09594ca5f77
Use chunked encoding for HTTP uploads. Patch by Tomas H¸«£rdin
rbultje
parents:
5059
diff
changeset
|
386 return ret; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
387 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
388 |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3286
diff
changeset
|
389 static int64_t http_seek(URLContext *h, int64_t off, int whence) |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
390 { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
391 HTTPContext *s = h->priv_data; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
392 URLContext *old_hd = s->hd; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3286
diff
changeset
|
393 int64_t old_off = s->off; |
5544
fc48f8bfbf2e
restore old buffer content when seek failed in http protocol, fix issue #1631
bcoudurier
parents:
5527
diff
changeset
|
394 uint8_t old_buf[BUFFER_SIZE]; |
fc48f8bfbf2e
restore old buffer content when seek failed in http protocol, fix issue #1631
bcoudurier
parents:
5527
diff
changeset
|
395 int old_buf_size; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
396 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
397 if (whence == AVSEEK_SIZE) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
398 return s->filesize; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
399 else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
400 return -1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
401 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
402 /* we save the old context in case the seek fails */ |
5544
fc48f8bfbf2e
restore old buffer content when seek failed in http protocol, fix issue #1631
bcoudurier
parents:
5527
diff
changeset
|
403 old_buf_size = s->buf_end - s->buf_ptr; |
fc48f8bfbf2e
restore old buffer content when seek failed in http protocol, fix issue #1631
bcoudurier
parents:
5527
diff
changeset
|
404 memcpy(old_buf, s->buf_ptr, old_buf_size); |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
405 s->hd = NULL; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
406 if (whence == SEEK_CUR) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
407 off += s->off; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
408 else if (whence == SEEK_END) |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
409 off += s->filesize; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
410 s->off = off; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
411 |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
412 /* if it fails, continue on old connection */ |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
413 if (http_open_cnx(h) < 0) { |
5544
fc48f8bfbf2e
restore old buffer content when seek failed in http protocol, fix issue #1631
bcoudurier
parents:
5527
diff
changeset
|
414 memcpy(s->buffer, old_buf, old_buf_size); |
fc48f8bfbf2e
restore old buffer content when seek failed in http protocol, fix issue #1631
bcoudurier
parents:
5527
diff
changeset
|
415 s->buf_ptr = s->buffer; |
fc48f8bfbf2e
restore old buffer content when seek failed in http protocol, fix issue #1631
bcoudurier
parents:
5527
diff
changeset
|
416 s->buf_end = s->buffer + old_buf_size; |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
417 s->hd = old_hd; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
418 s->off = old_off; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
419 return -1; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
420 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
421 url_close(old_hd); |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
422 return off; |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
423 } |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
424 |
4640
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
425 static int |
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
426 http_get_file_handle(URLContext *h) |
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
427 { |
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
428 HTTPContext *s = h->priv_data; |
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
429 return url_get_file_handle(s->hd); |
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
430 } |
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
431 |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
432 URLProtocol http_protocol = { |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
433 "http", |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
434 http_open, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
435 http_read, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
436 http_write, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
437 http_seek, |
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
438 http_close, |
4640
b34d9614b887
Add url_get_file_handle(), which is used to get the file descriptor
rbultje
parents:
4630
diff
changeset
|
439 .url_get_file_handle = http_get_file_handle, |
1822
2526fc1e568b
Reverting stray commit part II, r8156 had the base64 export patch mixed with the nutdec patch
lu_zero
parents:
diff
changeset
|
440 }; |