summaryrefslogtreecommitdiff
path: root/libavformat/http.c
Commit message (Collapse)AuthorAge
* avformat/http: Remove deprecated "user-agent" optionAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in 27714b462d1bff9e9b40fbdabb39f58e79032b81. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/http,tls: honor http_proxy command line variable for HTTPSMoritz Barsnick2021-03-19
| | | | | | | | | | | | | | | | | | Add the "http_proxy" option and its handling to the "tls" protocol, pass the option from the "https" protocol. The "https" protocol already defines the "http_proxy" command line option, like the "http" protocol does. The "http" protocol properly honors that command line option in addition to the environment variable. The "https" protocol doesn't, because the proxy is evaluated in the underlying "tls" protocol, which doesn't have this option, and thus only handles the environment variable, which it has access to. Fixes #7223. Signed-off-by: Moritz Barsnick <barsnick@gmx.net> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/http: Fix leak when using deprecated optionAndreas Rheinhardt2021-03-07
| | | | | | | | | | | | When the deprecated option "user-agent" was set to something different than its default value, said option would always precede and overwrite the ordinary user_agent option (regardless of whether it was explicitly set) which leads to a leak of the user_agent option (which has a default value, so the leak happens always). Fix this by setting the same destination for both options; the last option applied wins then. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavf/http: treat 308 as 301Robin Cooksey2021-01-25
| | | | | | | FFmpeg does not support POST, so there is no difference between a 308 and 301 request (see [RFC7538] section 3). Signed-off-by: Josh Dekker <josh@itanimul.li>
* avformat/http: support retry on connection errorerankor2021-01-03
| | | | | | | | | | | | | | | | | | Add 2 new options: - reconnect_on_http_error - a list of http status codes that should be retried. the list can contain explicit status codes / the strings 4xx/5xx. - reconnect_on_network_error - reconnects on arbitrary errors during connect, e.g. ECONNRESET/ETIMEDOUT the retry employs the same exponential backoff logic as the existing reconnect/reconnect_at_eof flags. related tickets: https://trac.ffmpeg.org/ticket/6066 https://trac.ffmpeg.org/ticket/7768 Signed-off-by: Marton Balint <cus@passwd.hu>
* http: Check for AVERROR_EOF in the check for premature endMartin Storsjö2020-11-20
| | | | | | | | | | | When the check was added (in 3668701f9600, in 2015), some IO functions returned 0 on EOF (in particular, the TCP protocol did, but the TLS protocol returned AVERROR_EOF). Since 0e1f771d2200d in 2017, the TCP protocol also returns AVERROR_EOF instead of 0, making the check for premature end never have the intended effect. Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/http: fix memleakZhao Zhili2020-09-25
| | | | | Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/http: increase BUFFER_SIZE to MAX_URL_SIZE + HTTP_HEADERS_SIZEJoey Smith2020-05-21
| | | | | | | | | | | | | Some real-world sites use an authorization header with a bearer token; when combined with lengthy request parameters to identify the video segment, it's rather trivial these days to have a request body of more than 4k bytes. MAX_URL_SIZE is hard-coded to 4k bytes in libavformat/internal.h, and HTTP_HEADERS_SIZE is 4k as well in libavformat/http.h, so this patch increases the buffer size to 8k, as that is the default request body limit in Apache, and most other httpds seem to support at least as much, if not more. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/http: Fix for invalid use of av_strtokLimin Wang2020-05-10
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/http: escape unsafe URL path in HTTP requestMarton Balint2020-02-15
| | | | | | | This avoids generating invalid HTTP requests if the path contains space or other special characters. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/http: use AVBPrint to construct HTTP requestMarton Balint2020-02-15
| | | | | | | v2: Use s->buffer for creating request (as the old code did) instead of the AVBPrint internal buffer. Some minor cosmetics. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/http: make sure URL path contains a slashMarton Balint2020-02-15
| | | | | | | | | It is explicitly required by the HTTP RFC. Without this patch URLs like http://example.com?query will not work. Fixes ticket #8466. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/http: split the fragment part from the HTTP URL before the requestMarton Balint2020-02-15
| | | | | | | | RFC 3986 states that the fragment identifier is separated from the rest of the URI prior to a dereference, and thus the identifying information within the fragment itself is dereferenced solely by the user agent. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/hls: support data protocol in uri for EXT-X-MAPSteven Liu2020-01-18
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/http: add ff_http_do_new_request2 for optionsvectronic2019-10-08
| | | | | | | | add ff_http_do_new_request2() which supports options to be applied to HTTPContext after initialisation with the new uri Signed-off-by: Steven Liu <lq@onvideo.cn> Signed-off-by: vectronic <hello.vectronic@gmail.com>
* avformat/http: add ff_http_get_shutdown_status api for check the status of ↵Steven Liu2019-09-06
| | | | | | | | | shutdown this function is used to get the previous shutdown status when reusing the old connection in block mode. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/http: change error message from numeric code to stringSteven Liu2019-07-11
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/doc, http, icecast, rtsp: Add option to disable send-expect-100Jun Li2019-03-31
| | | | | | | | | | Fix ticket #7297 The current setting for send-expect-100 option is either enabled if applicable or forced enabled, no option to force disable the header. This change is to expand the option setting to provide more flexibility, which is useful for rstp case. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/http: Print metadata updates with -loglevel verbose.Carl Eugen Hoyos2019-03-20
| | | | Simplifies metadata debugging.
* http: Do not try to make a new request when seeking past the end of the fileJustin Ruggles2019-02-26
| | | | | | | | | | This avoids making invalid HTTP Range requests for a byte range past the known end of the file during a seek. Those requests generally return a HTTP response of 416 Range Not Satisfiable, which causes an error response. Reference: https://tools.ietf.org/html/rfc7233 Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* avformat/http: Fix Out-of-Bounds access in process_line()Wenxiang Qian2019-02-17
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* 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>