VLC  4.0.0-dev
resource.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * resource.h: HTTP resource common code
3  *****************************************************************************
4  * Copyright (C) 2015 RĂ©mi Denis-Courmont
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20 
21 #ifndef VLC_HTTP_RESOURCE_H
22 #define VLC_HTTP_RESOURCE_H 1
23 
24 /**
25  * \defgroup http_res Resources
26  * Remote HTTP resources identified by a URL
27  * \ingroup http
28  * @{
29  */
30 
31 struct vlc_http_msg;
32 struct vlc_http_mgr;
33 struct vlc_http_resource;
34 
36 {
37  int (*request_format)(const struct vlc_http_resource *,
38  struct vlc_http_msg *, void *);
39  int (*response_validate)(const struct vlc_http_resource *,
40  const struct vlc_http_msg *, void *);
41 };
42 
44 {
45  const struct vlc_http_resource_cbs *cbs;
48  bool secure;
49  bool negotiate;
50  bool failure;
51  char *host;
52  unsigned port;
53  char *authority;
54  char *path;
55  char *username;
56  char *password;
57  char *agent;
58  char *referrer;
59 };
60 
62  const struct vlc_http_resource_cbs *cbs,
63  struct vlc_http_mgr *mgr,
64  const char *uri, const char *ua, const char *ref);
65 
66 /**
67  * Destroys an HTTP resource.
68  *
69  * Releases all underlying resources allocated or held by the HTTP resource
70  * object.
71  */
73 
74 struct vlc_http_msg *vlc_http_res_open(struct vlc_http_resource *res, void *);
76 
77 /**
78  * Gets redirection URL.
79  *
80  * Checks if the resource URL lead to a redirection. If so, return the redirect
81  * location.
82  *
83  * @return Heap-allocated URL or NULL if no redirection.
84  */
86 
87 /**
88  * Gets MIME type.
89  *
90  * @return Heap-allocated MIME type string, or NULL if unknown.
91  */
93 
94 /**
95  * Reads data.
96  */
98 
100  const char *username, const char *password);
102 
103 /** @} */
104 #endif
char * path
Definition: resource.h:54
Definition: connmgr.c:99
struct vlc_http_mgr * manager
Definition: resource.h:47
char * vlc_http_res_get_redirect(struct vlc_http_resource *)
Gets redirection URL.
int(* request_format)(const struct vlc_http_resource *, struct vlc_http_msg *, void *)
Definition: resource.h:37
int vlc_http_res_set_login(struct vlc_http_resource *res, const char *username, const char *password)
Definition: resource.c:331
struct vlc_http_msg * vlc_http_res_open(struct vlc_http_resource *res, void *)
Definition: resource.c:84
char * vlc_http_res_get_type(struct vlc_http_resource *)
Gets MIME type.
Definition: resource.c:312
char * password
Definition: resource.h:56
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)
bool failure
Definition: resource.h:50
Definition: resource.h:43
bool negotiate
Definition: resource.h:49
Definition: resource.h:35
void vlc_http_res_destroy(struct vlc_http_resource *)
Destroys an HTTP resource.
Definition: resource.c:162
char * host
Definition: resource.h:51
bool secure
Definition: resource.h:48
char * agent
Definition: resource.h:57
unsigned port
Definition: resource.h:52
int(* response_validate)(const struct vlc_http_resource *, const struct vlc_http_msg *, void *)
Definition: resource.h:39
Definition: message.c:41
char * username
Definition: resource.h:55
char * vlc_http_res_get_basic_realm(struct vlc_http_resource *res)
Definition: resource.c:365
Definition: vlc_block.h:117
struct block_t * vlc_http_res_read(struct vlc_http_resource *)
Reads data.
Definition: resource.c:322
const struct vlc_http_resource_cbs * cbs
Definition: resource.h:45
char * referrer
Definition: resource.h:58
struct vlc_http_msg * response
Definition: resource.h:46
int vlc_http_res_get_status(struct vlc_http_resource *res)
Definition: resource.c:131
char * authority
Definition: resource.h:53