int ff_http_averror(int status_code, int default_averror)
This helper function returns AVERROR_ value from 3-digit HTTP status
code.
Second argument, default_averror, is used if no specific AVERROR_ is
available. It is introduced because in different places of code
different return codes are used - -1, AVERROR(EIO), AVERROR_INVALIDDATA.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
The current code would use any unknown attribute-value pair
as the cookie value.
RFC 6265 states that the first key-value pair is the actual
cookie, and the attribute-value pairs only start after.
With the current code:
Set-Cookie: test=good_value; path=/; dummy=42
gives this:
Cookie: dummy=42
instead of this with the new code:
Cookie: test=good_value
* commit '7ccb847f0f1f28199fa254847b91b6e50fb92832':
http: Reduce scope of a variable in parse_content_encoding()
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '7601f9412a2d3387617a45966b65b452a632c27a':
http: export icecast metadata as an option with name "metadata".
Merged-by: Michael Niedermayer <michaelni@gmx.at>
The cur_*auth_type variables were set before the http_connect call
prior to 6a463e7fb - their sole purpose is to record the
authentication type used to do the latest request, since parsing
the http response sets the new type in the auth state.
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
* commit '8bf3bf69ad7333bf0c45f4d2797fc2c61bc8922f':
http: Stop reading after receiving the whole file for non-chunked transfers
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Previously this logic was only used if the server didn't
respond with Connection: close, but use it even for that case,
if the server response is non-chunked.
Originally the http code has relied on Connection: close to close
the socket when the file/stream is received - the http protocol
code just kept reading from the socket until the socket was closed.
In f240ed18 we added a check for the file size, because some
http servers didn't respond with Connection: close (and wouldn't
close the socket) even though we requested it, which meant that the
http protocol blocked for a long time at the end of files, waiting
for a socket level timeout.
When reading over tls, trying to read at the end of the connection,
when the peer has closed the connection, can produce spurious (but
harmless) warnings. Therefore always voluntarily stop reading when
the specified file size has been received, if not using a chunked
transfer encoding. (For chunked transfers, we already return 0
as soon as we get the chunk header indicating end of stream.)
Signed-off-by: Martin Storsjö <martin@martin.st>
Split return value handling from the actual opening.
Incidentally fixes the https -> http redirect issue reported by
Compn on behalf of rcombs.
CC: libav-stable@libav.org
* commit '7bdd2ff6825951f7a6a6008303acfce7c2a63532':
http: Use a constant for the supported header size
Conflicts:
libavformat/http.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '389380c27915b0505fed538cd54c035c891fabd9':
http: Do move the class instantiation in the conditional block
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '28df1d24112c6ad0763985df2faeeb198cfbad69':
http: Provide an option to override the HTTP method
Merged-by: Michael Niedermayer <michaelni@gmx.at>
The authstr memory allocations make it annoying to error in the middle
of the header setup code, so apply the usual C error handling idiom to
make it easier to error at any point.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
If a domain has some cookies set, but matching the cookie fails due to
the port being different, get_cookies() succeeds, but sets cookies to
NULL. The caller of get_cookies() didn't check for the NULL value.
This also avoids passing NULL to libc string functions, which is
undefined behavior
Fixes Ticket2180
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* commit 'e77a2ea9505863e50bf013706f66bf8b7325e524':
http: Declare more parameters as const where possible
Merged-by: Michael Niedermayer <michaelni@gmx.at>
The icy_metadata_headers string never gets initialized, so,
during the first call to av_strlcatf() in parse_icy(),
strlen() will be called on a pointer to uninitialized memory.
At best this causes some garbage data to be left at the
start of the string.
By initializing icy_metadata_headers to the empty string, the
first call to strlen() will always return 0, so that data is
appended from the start of the string.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* qatar/master:
http: Allow setting a Content-Type for POST requests
Conflicts:
libavformat/http.c
See: c01d1d4ddf
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* commit '2ec33d27127251bbc45e1f88e60691ad59cf2319':
http: Add support for selecting a request range
Conflicts:
doc/protocols.texi
libavformat/http.c
See: d52882faef
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Export the metadata as a icy_metadata_packet avoption.
Based on the work of wm4 and Alessandro Ghedini.
Bug-Id: https://bugs.debian.org/739936
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>