Certain servers accept only PUT as valid method.
---
 libavformat/http.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 948930a..664f706 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -43,6 +43,11 @@
 #define BUFFER_SIZE MAX_URL_SIZE
 #define MAX_REDIRECTS 8
 
+enum {
+    HTTP_POST,
+    HTTP_PUT
+};
+
 typedef struct {
     const AVClass *class;
     URLContext *hd;
@@ -85,6 +90,7 @@ typedef struct {
 #endif
     AVDictionary *chained_options;
     int send_expect_100;
+    int write_method;
 } HTTPContext;
 
 #define OFFSET(x) offsetof(HTTPContext, x)
@@ -110,6 +116,9 @@ 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_INT, { .i64 = HTTP_POST }, 0, 0, E, "write_method" },
+{"post", "POST method", 0, AV_OPT_TYPE_CONST, { .i64 = HTTP_POST }, 0, 0, E, 
"write_method" },
+{"put", "PUT method", 0, AV_OPT_TYPE_CONST, { .i64 = HTTP_PUT }, 0, 0, E, 
"write_method" },
 {NULL}
 };
 #define HTTP_CLASS(flavor)\
@@ -555,7 +564,20 @@ static int http_connect(URLContext *h, const char *path, 
const char *local_path,
         s->chunked_post = 0;
     }
 
-    method = post ? "POST" : "GET";
+    if (post) {
+        switch (s->write_method) {
+        case HTTP_PUT:
+            method = "PUT";
+            break;
+        default:
+        case HTTP_POST:
+            method = "POST";
+            break;
+        }
+    } else {
+        method = "GET";
+    }
+
     authstr = ff_http_auth_create_response(&s->auth_state, auth, local_path,
                                            method);
     proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, 
proxyauth,
-- 
1.9.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to