On Fri, 18 Jul 2014, Luca Barbato wrote:
Certain servers accept only PUT as valid method. ---Now w/out the stray enum. libavformat/http.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 948930a..cb800ce 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -85,6 +85,7 @@ typedef struct { #endif AVDictionary *chained_options; int send_expect_100; + char *write_method; } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) @@ -110,6 +111,7 @@ static const AVOption options[] = { {"location", "The actual location of the data received", OFFSET(location), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E }, {"offset", "initial byte offset", OFFSET(off), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D }, {"end_offset", "try to limit the request to bytes preceding this offset", OFFSET(end_off), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D }, +{"write_method", "Method to write to the remote server", OFFSET(write_method), AV_OPT_TYPE_STRING, { .str = "POST" }, 0, 0, E, }, {NULL} }; #define HTTP_CLASS(flavor)\ @@ -555,7 +557,12 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, s->chunked_post = 0; } - method = post ? "POST" : "GET"; + if (post) { + method = s->write_method; + } else { + method = "GET"; + } +
I still think it would make even more sense to allow this even for the reading mode as well. I don't have any specific use case in mind, but it would feel stupid to have to add a separate read_method if we later come up with such a use case.
The risk of someone shooting themselves in the foot with it doesn't feel that big either - and in case they do, it should be pretty clear what happened.
In that case you can't set a default for this in the avoptions table, but check whether the method string is set and not empty, otherwise use the default POST/GET.
// Martin _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
