summaryrefslogtreecommitdiff
path: root/libavformat/http.c
Commit message (Collapse)AuthorAge
* fftools, avfilter, avformat: Simplify check for "is dictionary empty?"Andreas Rheinhardt2024-05-20
| | | | | Reviewed-by: epirat07@gmail.com Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/http: Add support for Retry-After headerDerek Buitenhuis2024-04-25
| | | | | | | | | | | | | | | | | 429 and 503 codes can, and often do (e.g. all Google Cloud Storage URLs can), return a Retry-After header with the error, indicating how long to wait, asd either a date, or in seconds, before retrying again. If it is not respected by, for example, using our default backoff stratetgy instead, chances of success are very unlikely. Some references: * https://datatracker.ietf.org/doc/html/rfc6585 * https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.3 This adds an AVOption to respect that header. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/http: Rename parse_set_cookie_expiry_time to parse_http_dateDerek Buitenhuis2024-04-25
| | | | | | | That is what it actually does, and it will be needed for more than the Expiry header soon. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/http: Add option to limit total reconnect delayDerek Buitenhuis2024-04-25
| | | | | | | | | | | | | The existing option only allows users to set the max delay for a single attempt, rather than the total allowed delay, which is both pretty unintitive, and only applicable when exponential backoff is used. The default for this option is set to 256, which is just above the effective total delay accomplished by the the existing reconnect_delay_max default of 120. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/http: Add options to set the max number of connection retriesDerek Buitenhuis2024-04-25
| | | | | | Not every use case benefits from setting retries in terms of the backoff. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/http: Rename attempts to auth_attemptsDerek Buitenhuis2024-04-25
| | | | | | | This accurately reflects what it does, as per e75bbcf493aeb549d04c56f49406aeee3950d93b. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/http: Don't bail on parsing headers on "bad" HTTP codesDerek Buitenhuis2024-04-25
| | | | | | | | | Many "bad" HTTP codes like 429 and 503 may include important info in their headers. Also, in general, there is no purpose in bailing here. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/http: Use AVERROR_HTTP_TOO_MANY_REQUESTSDerek Buitenhuis2024-04-25
| | | | | | Added in the previous commit. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-31
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-14
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-20
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-22
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Avoid including codec.h, frame.hAndreas Rheinhardt2023-09-07
| | | | | | | | | | | | | | | | AVCodec is only ever used as an incomplete type (i.e. via a pointer to an AVCodec) in avformat.h and it is not really part of the core of avformat.h or libavformat; almost none of our internal users make use of it (and none make use of hwcontext.h, which is implicitly included). So switch to use struct AVCodec, but continue to include codec.h for external users for compatibility. Also, do the same for AVFrame and frame.h, which is implicitly included by codec.h (via lavu/hwcontext.h). Also, remove an unnecessary inclusion of <time.h>. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/http: copy only mime type from Content-TypeKacper Michajłow2023-06-29
| | | | | | | | | Content-Type can include charset and boundary which is not a part of mime type and shouldn't be copied as such. Fixes HLS playback when the Content-Type includes additional fields. Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
* avformat/http: cookie path attribute should be optional not compulsoryMichael J. Walsh2023-03-08
| | | | | | | The path attribute in the Set-Cookie header is optional but treated by ffmpeg as being compulsory. Signed-off-by: Michael J. Walsh <mjfwalsh@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/http: use av_dict_iterateMarvin Scholz2022-12-01
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/http: include version.hJames Almer2022-06-24
| | | | | | | | This is needed to get LIBAVFORMAT_VERSION, used as part of the user agent. Fixes a recent regression. Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()Nil Admirari2022-06-21
| | | | | | | | | 1. getenv() is replaced with getenv_utf8() across libavformat. 2. New versions of AviSynth+ are now called with UTF-8 filenames. 3. Old versions of AviSynth are still using ANSI strings, but MAX_PATH limit on filename is removed. Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/http: remove unused function ff_http_get_shutdown_statusSteven Liu2022-05-12
| | | | | | ff_http_get_shutdown_status is unused after ticket 9010 fixed. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* http: Send a Range header even when the offset is 0Justin Ruggles2022-02-11
| | | | | | | Using Range allows for getting the full file size from the Content-Range header in the response, even if the server sends back the response using chunked Transfer-Encoding, which does not allow using Content-Length.
* http: Improve handling of Content-Range with Transfer-Encoding:chunkedJustin Ruggles2022-02-11
| | | | | | | When Transfer-Encoding:chunked is used, the client must ignore a Content-Length header, if present. However, it should not ignore a Content-Range header, which also includes the full size of the entity.
* avformat/http: Fix double-free on errorAndreas Rheinhardt2022-02-01
| | | | | | | | | | | av_dict_set() with AV_DICT_DONT_STRDUP_VAL takes ownership of the string it is passed to as val; this includes freeing it on error. Fixes Coverity issue #1497468. Reviewed-by: Eran Kornblau <eran.kornblau@kaltura.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* http: remove cache_redirect optionerankor2022-01-31
| | | | | | | | | following 625ea2d, redirect caching is performed according to the http response headers, there's no need to have it as an option - always start from the original uri, and apply any redirects according to the redirect_cache dictionary. Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* http: honor response headers in redirect cachingerankor2022-01-18
| | | | | | | | | | | | | | add a dictionary that maps "src_url" -> "expiry;dst_url", the dictionary is checked before issuing an http request, and updated after getting a 3xx redirect response. the cache expiry is determined according to the following (in desc priority) - 1. Expires header 2. Cache-Control containing no-cache/no-store (disables caching) 3. Cache-Control s-maxage/max-age 4. Http codes 301/308 are cached indefinitely, other codes are not cached
* http: make caching of redirect url optionalerankor2021-12-31
| | | | | | | | | | | added "cache_redirect" option to http. when enabled, requests issued after seek will use the latest redirected url. when disabled, each call to seek will revert to the original url that was sent to http_open. currently, the default remains 'enabled', until the next major libavformat bump, where it will change to 'disabled'.
* avformat/http: prevent truncation of sanitized_pathJames Almer2021-11-25
| | | | | | | | | path1 and sanitized_path are both MAX_URL_SIZE bytes long, yet the latter is copied from the former with the addition of one extra character. Should fix a -Wformat-truncation warning. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/http: Add short_seek_size optionDerek Buitenhuis2021-11-17
| | | | | | | | | | | | | | | In 45bfe8b838275235412777dd430206d9a24eb3ee, short_seek_threshold was removed from the public AVIO struct. Although this option was private and not intended to be used by public API users, it was nonetheless, because it provided functionality that could otherwise not be gained via public API. This was especially important for networked I/O like HTTP, where the internal size for lavf could be way to small depending on the specifics of a user's usecase, such as reading interlavd media files from cloud storage. Add an AVOption to make this functionality accessible to the HTTP client. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/http: Stop cookie_dict leaking on errors.Robert Bengtsson-Ölund2021-06-26
| | | | | | This solves the memory leak reported in https://trac.ffmpeg.org/ticket/9273 Signed-off-by: Robert Bengtsson-Ölund <robert.bengtsson-olund@intinor.se>
* 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>