summaryrefslogtreecommitdiff
path: root/libavformat/http.c
Commit message (Collapse)AuthorAge
...
* avformat/http: clarify that ffmpeg will attempt to add missing CRLFGyan Doshi2019-01-29
|
* avformat/http : Added check for valid URL context before calling shutdownkjeyapal@akamai.com2018-11-22
|
* lavf/http: use AV_OPT_FLAG_DEPRECATED for user-agent optionClément Bœsch2018-04-26
|
* avformat/http: flushing tcp receive buffer when it is write only modeVishwanath Dixit2018-04-20
| | | | | | | | | | | In write only mode, the TCP receive buffer's data keeps growing with http response messages and the buffer eventually becomes full. This results in zero tcp window size, which in turn causes unwanted issues, like, terminated tcp connection. The issue is apparent when http persistent connection is enabled in hls/dash live streaming use cases. To overcome this issue, the logic here reads the buffer data when a file transfer is completed, so that any accumulated data in the recieve buffer gets flushed out.
* lavf/http.c: Free allocated client URLContext in case of error.Stephan Holljes2018-04-20
| | | | | Signed-off-by: Stephan Holljes <klaxa1337@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavformat/http: Refactor and fix additional leaks in get_cookies.Richard Shaffer2018-04-19
| | | | | | | | | | This refactors get_cookies to simplify some code paths, specifically for skipping logic in the while loop or exiting it. It also simplifies the logic for appending additional values to *cookies by replacing strlen/malloc/snprintf with one call av_asnprintf. This refactor fixes a bug where the cookie_params AVDictionary would get leaked if we failed to allocate a new buffer for writing to *cookies.
* libavformat/http: Fix memory leak in get_cookies.Richard Shaffer2018-04-17
|
* http: fix potentially dangerous whitespace skipping codewm42018-03-18
| | | | | | | | | | | | | If the string consists entirely of whitespace, this could in theory continue to write '\0' before the start of the memory allocation. In practice, it didn't really happen: the generic HTTP header parsing code already skips leading whitespaces, so the string is either empty, or consists a non-whitespace. (The generic code and the cookie code actually have different ideas about what bytes are whitespace: the former uses av_isspace(), the latter uses WHITESPACES. Fortunately, av_isspace() is a super set of the http.c specific WHITESPACES, so there's probably no case where the above assumption could have been broken.)
* http: avoid out of bound accesses on broken Set-Cookie headerswm42018-03-18
| | | | | | | | It's trivial to craft a HTTP response that will make the code for skipping trailing whitespace access and possibly overwrite bytes outside of the memory allocation. Why this can happen is blindingly obvious: it accesses cstr[strlen(cstr)-1] without checking whether the string is empty.
* http: do not print a warning message for expired cookieswm42018-03-18
| | | | | | | libavformat prints a warning that the cookie couldn't be parsed (see callers of parse_cookie()). This is obviously not true - it could be parsed, but was simply ignored. Don't return an error to avoid the warning.
* avformat/http: add referer option into httpSteven Liu2018-02-01
| | | | | add Referer message if referer have been set. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* http: cosmetics: reformat reconnect check for better readabilitywm42018-01-15
| | | | | | | The condition was a bit too long, and most editors will break the line and turn it into an unreadable mess. Move out some of the conditions. This should not change the behavior.
* avformat/http: fix memory leak in parse_cookie.Richard Shaffer2018-01-12
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* http: avoid logging reconnect warning if stream was abortedwm42018-01-04
| | | | | | If the stream was aborted using the libavformat interrupt callback, we don't want it to log the reconnect warning. (Exiting after logging this warning worked well, so this is only for avoiding the ugly warning.)
* http: bump message level for reconnect message and log timeoutwm42018-01-04
|
* http: block while waiting for reconnectingwm42018-01-04
| | | | | | | | | | | | | | | | | | It makes no sense to return an error after the first reconnect, and then somehow resume the next time it's called. Usually this will lead to demuxer errors. Make reconnecting block instead, until it has either successfully reconnected, or given up. Also make the wait reasonably interruptible. Since there is no mechanism for this in the API, polling is the best we can do. This behaves roughly the same as other interruptible network functions in libavformat. (The original code would work if it returned AVERROR(EAGAIN) or so, which would make retry_transfer_wrapper() repeat the read call. But I think having an explicit loop for this is better anyway.) I also snuck in a fix for reconnect_at_eof. It has to check for AVERROR_EOF, not 0.
* avformat/http: return EINVAL if ff_http_do_new_request is called with ↵Aman Gupta2017-12-30
| | | | | | non-http URLContext Signed-off-by: Aman Gupta <aman@tmm1.net>
* avformat/http: export http_version from responseAman Gupta2017-12-26
| | | | | | Can be used by the api user to figure out what http features the server supports based on the response received. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avformat/http: avoid ff_http_do_new_request after http/1.0 responseAman Gupta2017-12-26
| | | | | | This makes do_new_request fail early when dealing with a http/1.0 server, avoiding unnecessary "reconnecting" warnings shown to the user. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avformat/http: Avoid calling http_shutdown() if end of chunk is signalled ↵Karthick Jeyapal2017-12-25
| | | | already
* avformat/http: return EOF from ff_http_do_new_request if previous response ↵Aman Gupta2017-12-22
| | | | | | | | | | | | said Connection:close This fixes a deadlock when using the hls demuxer's new http_persistent feature to stream a youtube live stream over HTTPS. The youtube servers are http/1.1 compliant, but return a "Connecton: close". Before this commit, the demuxer would attempt to send a new request on the partially shutdown connection and cause a deadlock in the tls protocol. Signed-off-by: Aman Gupta <aman@tmm1.net>
* avformat/http: add "Opening" info logging to ff_http_do_new_requestAman Gupta2017-12-22
| | | | | | | | This mimics logging that was added in 53e0d5d7247 for security purposes. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/http: return EINVAL from ff_http_do_new_request() if re-used with ↵Aman Gupta2017-12-22
| | | | | | | | | | | different hostname This will prevent improper use of ff_http_do_new_request() if the user tries to send a request for a different host to a previously connected persistent http/1.1 connection. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Karthick J <kjeyapal@akamai.com>
* libavformat/http: Handled multiple_requests option during writeJeyapal, Karthick2017-11-29
|
* avformat/http: fix chunked response w/ multiple_requests=1Aman Gupta2017-11-14
| | | | | | | | | | | | Currently if you use the multiple_requests=1 option and try to receive a chunked-encoded response, http_buf_read() will hang forever. After this patch, EOF is emulated once a 0-byte final chunk is received by setting a new flag. This flag is reset in ff_http_do_new_request(), which is used to make additional requests on the open socket. Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: Aman Gupta <aman@tmm1.net>
* avformat/http: fix stray quote in trace loggingAman Gupta2017-11-13
| | | | | Signed-off-by: Aman Gupta <aman@tmm1.net> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
* libavformat: not treat 0 as EOFDaniel Kucera2017-10-19
| | | | | | | | | | transfer_func variable passed to retry_transfer_wrapper are h->prot->url_read and h->prot->url_write functions. These need to return EOF or other error properly. In case of returning >= 0, url_read/url_write is retried until error is returned. Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
* lavf/http: fix compilation without zlibClément Bœsch2017-09-15
| | | | Regression since e2f8f14052d99d7710cda0a821e236765b315d0b.
* lavf/http: Reset compressed header flag, fix http 302 requestJacek Jendrzej2017-09-15
| | | | | | | Fixes ticket #6404. Fixes ticket #6666. Signed-off-by: Jacek Jendrzej <satbaby@kawaii.com>
* libavformat/http: return EIO when ffurl_read return 0, but s->off < target_endraymondzheng2017-06-09
| | | | | Approved-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavformat/http: Ignore expired cookiesMicah Galizia2017-05-01
| | | | | Signed-off-by: Micah Galizia <micahgalizia@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* HTTP: improve performance by reducing forward seeksJoel Cunningham2017-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit optimizes HTTP performance by reducing forward seeks, instead favoring a read-ahead and discard on the current connection (referred to as a short seek) for seeks that are within a TCP window's worth of data. This improves performance because with TCP flow control, a window's worth of data will be in the local socket buffer already or in-flight from the sender once congestion control on the sender is fully utilizing the window. Note: this approach doesn't attempt to differentiate from a newly opened connection which may not be fully utilizing the window due to congestion control vs one that is. The receiver can't get at this information, so we assume worst case; that full window is in use (we did advertise it after all) and that data could be in-flight The previous behavior of closing the connection, then opening a new with a new HTTP range value results in a massive amounts of discarded and re-sent data when large TCP windows are used. This has been observed on MacOS/iOS which starts with an initial window of 256KB and grows up to 1MB depending on the bandwidth-product delay. When seeking within a window's worth of data and we close the connection, then open a new one within the same window's worth of data, we discard from the current offset till the end of the window. Then on the new connection the server ends up re-sending the previous data from new offset till the end of old window. Example (assumes full window utilization): TCP window size: 64KB Position: 32KB Forward seek position: 40KB * (Next window) 32KB |--------------| 96KB |---------------| 160KB * 40KB |---------------| 104KB Re-sent amount: 96KB - 40KB = 56KB For a real world test example, I have MP4 file of ~25MB, which ffplay only reads ~16MB and performs 177 seeks. With current ffmpeg, this results in 177 HTTP GETs and ~73MB worth of TCP data communication. With this patch, ffmpeg issues 4 HTTP GETs and 3 seeks for a total of ~22MB of TCP data communication. To support this feature, the short seek logic in avio_seek() has been extended to call a function to get the short seek threshold value. This callback has been plumbed to the URLProtocol structure, which now has infrastructure in HTTP and TCP to get the underlying receiver window size via SO_RCVBUF. If the underlying URL and protocol don't support returning a short seek threshold, the default s->short_seek_threshold is used This feature has been tested on Windows 7 and MacOS/iOS. Windows support is slightly complicated by the fact that when TCP window auto-tuning is enabled, SO_RCVBUF doesn't report the real window size, but it does if SO_RCVBUF was manually set (disabling auto-tuning). So we can only use this optimization on Windows in the later case Signed-off-by: Joel Cunningham <joel.cunningham@me.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/http: Check for truncated buffers in http_connect()Michael Niedermayer2017-02-14
| | | | | | Reported-by: SleepProgger <security@gnutp.com> Reviewed-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* http: move chunk handling from http_read_stream() to http_buf_read().Ronald S. Bultje2016-12-05
|
* http: make length/offset-related variables unsigned.Ronald S. Bultje2016-12-05
| | | | Fixes #5992, reported and found by Paul Cher <paulcher@icloud.com>.
* avformat/http: Fix #ifdef FF_API_HTTP_USER_AGENTMichael Niedermayer2016-09-17
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/http: deprecate user-agent optionSteven Liu2016-09-17
|
* libavformat/http: add support for content_type option in listen modeMoritz Barsnick2016-08-14
| | | | | | | | | Instead of silently ignoring the content_type option in listen mode, apply its value to the provided "Content-Type:" header. Signed-off-by: Moritz Barsnick <barsnick@gmx.net> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavformat/http: add support for headers option in listen modeMoritz Barsnick2016-08-12
| | | | | | | | Instead of silently ignoring the headers option in listen mode, use the provided headers. Signed-off-by: Moritz Barsnick <barsnick@gmx.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/http: change seek_ret to int64Yuri Zats2016-06-16
| | | | | Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit 'fab8156b2f30666adabe227b3d7712fd193873b1'Derek Buitenhuis2016-04-21
|\ | | | | | | | | | | | | * commit 'fab8156b2f30666adabe227b3d7712fd193873b1': avio: Copy URLContext generic options into child URLContexts Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * avio: Copy URLContext generic options into child URLContextsMartin Storsjö2016-03-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since all URLContexts have the same AVOptions, such AVOptions will be applied on the outermost context only and removed from the dict, while they probably make sense on all contexts. This makes sure that rw_timeout gets propagated to the innermost URLContext (to make sure it gets passed to the tcp protocol, when opening a http connection for instance). Alternatively, such matching options would be kept in the dict and only removed after the ffurl_connect call. Signed-off-by: Martin Storsjö <martin@martin.st>
| * urlprotocol: receive a list of protocols from the callerAnton Khirnov2016-02-22
| | | | | | | | | | This way, the decisions about which protocols are available for use in any given situations can be delegated to the caller.
* | lavf/http: Add httpproxy to the default protocol whitelist.Carl Eugen Hoyos2016-03-14
| |
* | Use correct msvc type specifiers for ptrdiff_t and size_t.Carl Eugen Hoyos2016-03-09
| |
* | avformat: Add a protocol blacklisting APIDerek Buitenhuis2016-03-04
| | | | | | | | Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* | Merge commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d'Derek Buitenhuis2016-02-29
|\| | | | | | | | | | | | | | | | | | | | | This commit also disables the async fate test, because it used internal APIs in a non-kosher way, which no longer exists. * commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d': lavf: reorganize URLProtocols Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * lavf: reorganize URLProtocolsAnton Khirnov2016-02-22
| | | | | | | | | | | | | | | | | | | | Instead of a linked list constructed at av_register_all(), store them in a constant array of pointers. Since no registration is necessary now, this removes some global state from lavf. This will also allow the urlprotocol layer caller to limit the available protocols in a simple and flexible way in the following commits.
* | avformat/http: add crypto to default whitlist to get encrypted HLS working ↵Schenk, Michael2016-02-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | again I think we missed the crypto in the default_whitelist in case of http. Otherwise encrypted HLS will fail with [hls,applehttp @ 0x2af39c00] playlist[0] open_input [http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=236000-14.ts], start_seq_no [1], cur_seq_no [14] [hls,applehttp @ 0x2af39c00] open_input curseqno [14] startseqno [1] [hls,applehttp @ 0x2af39c00] HLS request for url 'http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=236000-14.ts', offset 0, playlist 0 [NULL @ 0x2af3a200] KEY_AES_128 seg->key [http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key] pls->key_url [http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans.key] [hls,applehttp @ 0x2af39c00] open_input [KEY_AES_128] [hls,applehttp @ 0x2af39c00] : c->persistence [0] [hls,applehttp @ 0x2af39c00] : c->probing [1] [hls,applehttp @ 0x2af39c00] : pls->input [NULL] [hls,applehttp @ 0x2af39c00] using normal http path for URL [crypto+http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes-audio=65000-video=236000-14.ts] [crypto @ 0x2aff7cc0] Protocol not on whitelist 'http,https,tls,rtp,tcp,udp! Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Update demuxers and protocols for protocol whitelist supportMichael Niedermayer2016-02-02
| | | | | | | | | | Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>