[vlc-devel] [PATCH 02/10][RFC][WIP] http: resource is now able to invoke other methods rather than only GETs
Diogo Silva
dbtdsilva at gmail.com
Thu Aug 17 03:08:10 CEST 2017
---
modules/access/http/file.c | 4 ++--
modules/access/http/live.c | 3 ++-
modules/access/http/resource.c | 8 ++++++--
modules/access/http/resource.h | 4 +++-
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/modules/access/http/file.c b/modules/access/http/file.c
index ce101f60d6..dd7dd6605f 100644
--- a/modules/access/http/file.c
+++ b/modules/access/http/file.c
@@ -118,8 +118,8 @@ struct vlc_http_resource *vlc_http_file_create(struct vlc_http_mgr *mgr,
if (unlikely(file == NULL))
return NULL;
- if (vlc_http_res_init(&file->resource, &vlc_http_file_callbacks, mgr,
- uri, ua, ref))
+ if (vlc_http_res_init(&file->resource, &vlc_http_file_callbacks,
+ mgr, uri, ua, ref, "GET"))
{
free(file);
return NULL;
diff --git a/modules/access/http/live.c b/modules/access/http/live.c
index 6daf967a68..21e561ef2d 100644
--- a/modules/access/http/live.c
+++ b/modules/access/http/live.c
@@ -63,7 +63,8 @@ struct vlc_http_resource *vlc_http_live_create(struct vlc_http_mgr *mgr,
if (unlikely(res == NULL))
return NULL;
- if (vlc_http_res_init(res, &vlc_http_live_callbacks, mgr, uri, ua, ref))
+ if (vlc_http_res_init(res, &vlc_http_live_callbacks,
+ mgr, uri, ua, ref, "GET"))
{
free(res);
res = NULL;
diff --git a/modules/access/http/resource.c b/modules/access/http/resource.c
index ca55b49375..cd001055fc 100644
--- a/modules/access/http/resource.c
+++ b/modules/access/http/resource.c
@@ -41,7 +41,7 @@ vlc_http_res_req(const struct vlc_http_resource *res, void *opaque)
{
struct vlc_http_msg *req;
- req = vlc_http_req_create("GET", res->secure ? "https" : "http",
+ req = vlc_http_req_create(res->method, res->secure ? "https" : "http",
res->authority, res->path);
if (unlikely(req == NULL))
return NULL;
@@ -154,6 +154,7 @@ static void vlc_http_res_deinit(struct vlc_http_resource *res)
free(res->path);
free(res->authority);
free(res->host);
+ free(res->method);
if (res->response != NULL)
vlc_http_msg_destroy(res->response);
@@ -180,7 +181,8 @@ static char *vlc_http_authority(const char *host, unsigned port)
int vlc_http_res_init(struct vlc_http_resource *restrict res,
const struct vlc_http_resource_cbs *cbs,
struct vlc_http_mgr *mgr,
- const char *uri, const char *ua, const char *ref)
+ const char *uri, const char *ua, const char *ref,
+ const char *method)
{
vlc_url_t url;
bool secure;
@@ -218,6 +220,8 @@ int vlc_http_res_init(struct vlc_http_resource *restrict res,
res->agent = (ua != NULL) ? strdup(ua) : NULL;
res->referrer = (ref != NULL) ? strdup(ref) : NULL;
+ res->method = method == NULL ? strdup("GET") : strdup(method);
+
const char *path = url.psz_path;
if (path == NULL)
path = "/";
diff --git a/modules/access/http/resource.h b/modules/access/http/resource.h
index 22b5abac64..e28260cc18 100644
--- a/modules/access/http/resource.h
+++ b/modules/access/http/resource.h
@@ -51,6 +51,7 @@ struct vlc_http_resource
char *host;
unsigned port;
char *authority;
+ char *method;
char *path;
char *username;
char *password;
@@ -61,7 +62,8 @@ struct vlc_http_resource
int vlc_http_res_init(struct vlc_http_resource *,
const struct vlc_http_resource_cbs *cbs,
struct vlc_http_mgr *mgr,
- const char *uri, const char *ua, const char *ref);
+ const char *uri, const char *ua, const char *ref,
+ const char *method);
/**
* Destroys an HTTP resource.
--
2.14.1
More information about the vlc-devel
mailing list