Commit Graph

259 Commits

Author SHA1 Message Date
Michael Niedermayer 56193d33be avformat/http: remove never twice executable loop
Fixes CID1197069

Reviewed-by: Tomas Härdin <tomas.hardin@codemill.se>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-14 20:44:15 +02:00
wm4 686e662676 http: restructure http_connect error handling path
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>
2014-03-23 05:56:35 +01:00
wm4 76c8fbc5f2 http: never send 'Cookie: (null)' to the server
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>
2014-03-21 20:32:09 +01:00
Michael Niedermayer 11ed7ec092 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  http: Properly initialize icy headers string

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 23:24:19 +01:00
Michael Niedermayer 7e6c6c45ec Merge commit 'e77a2ea9505863e50bf013706f66bf8b7325e524'
* commit 'e77a2ea9505863e50bf013706f66bf8b7325e524':
  http: Declare more parameters as const where possible

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 20:50:29 +01:00
Alessandro Ghedini 6998a9f4c4 http: Properly initialize icy headers string
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>
2014-03-12 20:13:36 +01:00
Martin Storsjö e77a2ea950 http: Declare more parameters as const where possible
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-03-12 13:24:58 +02:00
Michael Niedermayer cd25412f59 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  http: Allow setting a Content-Type for POST requests

Conflicts:
	libavformat/http.c

See: c01d1d4ddf
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 04:53:54 +01:00
Michael Niedermayer 1cc9468289 Merge commit 'ab76d9f628ad46e1d3bbf26c5bf1f87083f239ab'
* commit 'ab76d9f628ad46e1d3bbf26c5bf1f87083f239ab':
  http: Always allow no-op seek

Conflicts:
	libavformat/http.c

See: 857841c1b6
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 04:29:54 +01:00
Michael Niedermayer 76a939d0e5 Merge commit '2ec33d27127251bbc45e1f88e60691ad59cf2319'
* 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>
2014-03-12 04:12:30 +01:00
Michael Niedermayer f36da16ede Merge commit 'ddfc98906373d1f17f6205cedd14c68d7a75995f'
* commit 'ddfc98906373d1f17f6205cedd14c68d7a75995f':
  http: Support setting custom User-Agent

Conflicts:
	doc/protocols.texi
	libavformat/http.c

See: 2bb1c713cc
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 03:45:16 +01:00
Michael Niedermayer c03af3ac1c Merge commit 'e58c85b0686892960042232e51c77168b264838a'
* commit 'e58c85b0686892960042232e51c77168b264838a':
  http: Export Content-Type information

Conflicts:
	doc/protocols.texi
	libavformat/http.c

See: 76d851b656
See: 20899c54f0
See: 255ec768da
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 03:33:14 +01:00
Michael Niedermayer ca2369cdee Merge commit '8075c3d8bb1f6aade0cc7c5c40db9bc1bcd84cab'
* commit '8075c3d8bb1f6aade0cc7c5c40db9bc1bcd84cab':
  http: Add support reading ICY metadata

Conflicts:
	doc/protocols.texi
	libavformat/http.c

See: a92fbe16f2
See: 636273d3d4
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 03:18:12 +01:00
Michael Niedermayer 21d4c571fa Merge commit '4ff99ab3d7d5576e99e6b8a411b4a44500ed88fa'
* commit '4ff99ab3d7d5576e99e6b8a411b4a44500ed88fa':
  http: Refactor process_line

Conflicts:
	libavformat/http.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 02:52:17 +01:00
Michael Niedermayer df41cbee85 Merge commit '7a2fddb4480121712df560cf619c1c3566cae3ff'
* commit '7a2fddb4480121712df560cf619c1c3566cae3ff':
  http: K&R formatting cosmetics

Conflicts:
	libavformat/http.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 02:45:34 +01:00
Michael Niedermayer b752d02f42 Merge commit '78b21c1d7177e1d61ad3c9225f67699da089aa7c'
* commit '78b21c1d7177e1d61ad3c9225f67699da089aa7c':
  http: Drop doxy comments

Conflicts:
	libavformat/http.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 02:39:46 +01:00
Michael Niedermayer 03fd80dcb1 Merge commit '55a215ba63d9fa79cd7ee265ee2e777ee86b200c'
* commit '55a215ba63d9fa79cd7ee265ee2e777ee86b200c':
  http: Return meaningful error codes

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-12 02:34:02 +01:00
Clément Bœsch 2572d07c1f http: Allow setting a Content-Type for POST requests
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-03-11 22:08:57 +01:00
Anssi Hannula ab76d9f628 http: Always allow no-op seek
This also allows checking stream position as per ffurl_seek() doxy.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-03-11 22:08:57 +01:00
Anssi Hannula 2ec33d2712 http: Add support for selecting a request range
Comment from Reimar Döffinger included as pro memoria.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-03-11 22:08:57 +01:00
Clément Bœsch ddfc989063 http: Support setting custom User-Agent
Contextually make the default User-Agent use the common
"Name/Version" pattern.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-03-11 22:08:57 +01:00
Michael Niedermayer e58c85b068 http: Export Content-Type information
Bug-Id: https://bugs.debian.org/740421

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-03-11 22:08:57 +01:00
Luca Barbato 8075c3d8bb http: Add support reading ICY metadata
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>
2014-03-11 22:08:57 +01:00
Alessandro Ghedini fe568b3d27 http: Improve options descriptions
Add documentation where missing.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-03-11 22:08:57 +01:00
Luca Barbato 4ff99ab3d7 http: Refactor process_line 2014-03-11 22:08:56 +01:00
Luca Barbato 7a2fddb448 http: K&R formatting cosmetics 2014-03-11 22:08:56 +01:00
Luca Barbato 78b21c1d71 http: Drop doxy comments 2014-03-11 22:08:56 +01:00
Luca Barbato 55a215ba63 http: Return meaningful error codes 2014-03-11 22:08:56 +01:00
Michael Niedermayer c832bf0c38 Merge remote-tracking branch 'lukaszmluki/master'
* lukaszmluki/master:
  lavd/avdevice: always free detected devices on error
  lavf/http: return error from seek on invalid whence
  lavf/http: return error on seeking to negative postion
  lavf/avio: fix ffurl_alloc error checks

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-06 02:04:18 +01:00
Lukasz Marek 1aa262f460 lavf/http: return error from seek on invalid whence
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
2014-03-06 00:32:24 +01:00
Lukasz Marek 4ba6a534dc lavf/http: return error on seeking to negative postion
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
2014-03-06 00:32:20 +01:00
wm4 636273d3d4 http: handle ICY in presence of chunked transfer encoding
Some http servers send an ICY stream in combination with chunked
transfer encoding. This case was handled incorrectly by the ICY code:
instead of handling chunked encoding before anything ICY related, both
were mixed.

Fix this by separating the ICY code from normal http reading. Move the
normal http reading to a new function http_read_stream(), while
http_read() handles ICY on top of http_read_stream().

The server identified itself as: cloudflare-nginx

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-05 22:49:36 +01:00
Eli Kara da25a6573f avformat/http: Properly handle cookies that specify sub-domain where the URL.
Fixes ticket #3336

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-23 14:39:36 +01:00
Anssi Hannula 857841c1b6 avformat/http: always allow no-op seek
This also allows checking stream position as per ffurl_seek() doxy.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-01-03 15:05:48 +02:00
Anssi Hannula d52882faef avformat/http: allow the caller to select a request range
Add AVOptions for setting the initial offset and the ending offset, so
they can be used for setting an appropriate Range header.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2013-12-31 03:18:53 +02:00
Michael Niedermayer 15b2ec57cc Merge commit 'be4edda6731a341d3fdeaa0e57753dc396790362'
* commit 'be4edda6731a341d3fdeaa0e57753dc396790362':
  http: Expose the content location via an AVOption

Conflicts:
	libavformat/http.c
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-22 17:48:45 +01:00
Michael Niedermayer 1d19f1b196 Merge commit '393d80cc278e2b2f5c9e7805db176e6f28335a33'
* commit '393d80cc278e2b2f5c9e7805db176e6f28335a33':
  http: Support relative URL redirection

Conflicts:
	libavformat/http.c

See: 4a4c93cb3f
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-22 17:41:45 +01:00
Michael Niedermayer 6d648dcfc9 Merge commit '76267ecc82e3018e1913a2483d5fc47d0949cbd8'
* commit '76267ecc82e3018e1913a2483d5fc47d0949cbd8':
  http: Remove an unrelated and mistakenly set AVOption unit name

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-22 17:18:52 +01:00
Martin Storsjö be4edda673 http: Expose the content location via an AVOption
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-11-22 14:27:07 +02:00
Zhang Rui 393d80cc27 http: Support relative URL redirection
In RFC 2616, this was explicitly said to be an absolute URL,
while in an upcoming draft [1] it is allowed to be relative as well.

[1] http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-25#section-7.1.2

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-11-22 14:27:04 +02:00
Martin Storsjö 76267ecc82 http: Remove an unrelated and mistakenly set AVOption unit name
This was due to a copypaste oversight.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-11-22 14:27:01 +02:00
Michael Niedermayer 04047b6166 avformat/http: print http headers at AV_LOG_DEBUG level
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-05 01:38:08 +01:00
wm4 3220a894f7 http: add hack to make streams served by MediaGateway not seekable
These streams are reported as seekable, but all tests show they are not,
and the server merely pretends the streams are seekable. The server
responds with:

    content-range: bytes 0-1999999999/2000000000

Range requests seem to be correctly answered, but the actual data
returned at the same offset is different. Assume this is a bug in the
server software. The server identifies itself as:

    Server: MediaGateway 3.5.2-001

Add a hack that checks the server name, and disables seeking in this
case.

Test URL: http://8283.live.streamtheworld.com:80/CBC_R1_VCR_H_SC

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-03 22:57:56 +01:00
Michael Niedermayer b73900b8a6 avformat/http: fix cookies
Fixes Ticket3096

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-31 01:42:13 +01:00
Michael Niedermayer d2db1bb7de avformat/http: dont fail with unknown Content-Encodings
Fixes: http://m1.file.xiami.com/282/23282/343749/1769075752_709488_l.mp3

Based-on-patch-by: Crossle Song <sxm@yixia.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-26 19:20:01 +02:00
Michael Niedermayer 0a6ce255ab Merge remote-tracking branch 'qatar/master'
* qatar/master:
  http: Check the auth string contents and not only the pointer

Conflicts:
	libavformat/http.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-15 09:34:27 +02:00
Michael Niedermayer 708b32b6f7 http: Check the auth string contents and not only the pointer
This makes sure we don't send the Except: 100-continue header
if no authentication credentials have been provided.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-14 21:57:15 +03:00
Michael Niedermayer 5970f4bb02 avformat/http: check the auth string contents not the pointer which cannot be NULL
It appears this bug originates from a "work in progress" patch from
ffmpeg-devel that was heavily redesigned by and integrated in libav

And that patch even had a reply and review on the mailing list pointing
out that it had a bug.

This fixes a deadlock with ffserver

See: [FFmpeg-devel] [PATCH] Fix HTTP authentication problem for POST actions.
     [FFmpeg-devel] [PATCH 1/3] Introduce auth_phase flag, which will be true if authorization needs to be sent, but the type of authorization is not known yet Partial fix #3036
     [FFmpeg-devel] [PATCH 2/3] Only add Transfer-Encoding header when not in authorization phase, because server will wait (indefinitely) for data when receiving this header Partial fix #3036
     [FFmpeg-devel] [PATCH 3/3] Only allow posting data and/or forcing a 200 code, enabling posting isml chunks, -after- we did a possible first request to get a 403 from the server telling us which type of authentication to apply Final part fix #3036
See: 71549a857b
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-14 01:35:28 +02:00
Michael Niedermayer 6b1b63df85 Merge commit '71549a857b13edf4c4f95037de6ed5bb4c4bd4af'
* commit '71549a857b13edf4c4f95037de6ed5bb4c4bd4af':
  http: Support auth method detection for POST

Conflicts:
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-14 00:37:01 +02:00
Michael Niedermayer 5dee3e8bb4 Merge commit 'eb8b05a3824a9fa85e20d603595ac8a3b83505d4'
* commit 'eb8b05a3824a9fa85e20d603595ac8a3b83505d4':
  http: Add an option for forcing basic authentication

Conflicts:
	libavformat/http.c
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-14 00:17:49 +02:00