VLC  4.0.0-dev
message.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * message.h: HTTP request/response
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 #include <stdint.h>
22 
23 /**
24  * \defgroup http_msg Messages
25  * HTTP messages, header formatting and parsing
26  * \ingroup http
27  * @{
28  * \file message.h
29  */
30 
31 struct vlc_http_msg;
32 struct block_t;
34 
35 /**
36  * Creates an HTTP request.
37  *
38  * Allocates an HTTP request message.
39  *
40  * @param method request method (e.g. "GET")
41  * @param scheme protocol scheme (e.g. "https")
42  * @param authority target host (e.g. "www.example.com:8080")
43  * @param path request path (e.g. "/dir/page.html")
44  * @return an HTTP stream or NULL on allocation failure
45  */
46 struct vlc_http_msg *
47 vlc_http_req_create(const char *method, const char *scheme,
48  const char *authority, const char *path) VLC_USED;
49 
50 /**
51  * Creates an HTTP response.
52  *
53  * Allocates an HTTP response message.
54  *
55  * @param status HTTP status code
56  * @return an HTTP stream or NULL on allocation failure
57  */
59 
60 /**
61  * Destroys an HTTP message.
62  */
63 void vlc_http_msg_destroy(struct vlc_http_msg *);
64 
65 /**
66  * Formats a header field.
67  *
68  * Adds an HTTP message header to an HTTP request or response.
69  * All headers must be formatted before the message is sent.
70  *
71  * @param name header field name
72  * @param fmt printf-style format string
73  * @return 0 on success, -1 on error (out of memory)
74  */
75 int vlc_http_msg_add_header(struct vlc_http_msg *, const char *name,
76  const char *fmt, ...) VLC_FORMAT(3,4);
77 
78 /**
79  * Formats an authority.
80  *
81  * @param host host name (cannot be NULL)
82  * @param port port number (0 for unspecified)
83  * @return the formatted authority as a heap-allocated nul-terminated string,
84  * or NULL on allocation failure
85  */
86 char *vlc_http_authority(const char *host, unsigned port);
87 
88 /**
89  * Sets the agent field.
90  *
91  * Sets the User-Agent or Server header field.
92  */
93 int vlc_http_msg_add_agent(struct vlc_http_msg *, const char *);
94 
95 /**
96  * Gets the agent field.
97  *
98  * Gets the User-Agent or Server header field.
99  */
100 const char *vlc_http_msg_get_agent(const struct vlc_http_msg *);
101 
102 /**
103  * Parses a timestamp header field.
104  *
105  * @param name header field name
106  * @return a timestamp value, or -1 on error.
107  */
108 time_t vlc_http_msg_get_time(const struct vlc_http_msg *, const char *name);
109 
110 /**
111  * Adds a timestamp header field.
112  *
113  * @param name header field name
114  * @param t pointer to timestamp
115  * @return 0 on success, -1 on error (errno is set accordingly)
116  */
117 int vlc_http_msg_add_time(struct vlc_http_msg *, const char *name,
118  const time_t *t);
119 
120 /**
121  * Adds a Date header field.
122  */
124 
125 /**
126  * Gets message date.
127  *
128  * Extracts the original date of the message from the HTTP Date header.
129  *
130  * @return a time value on success, -1 on error.
131  */
132 time_t vlc_http_msg_get_atime(const struct vlc_http_msg *);
133 
134 /**
135  * Gets resource date.
136  *
137  * Extracts the last modification date of the message content from the HTTP
138  * Last-Modified header.
139  *
140  * @return a time value on success, -1 on error.
141  */
142 time_t vlc_http_msg_get_mtime(const struct vlc_http_msg *);
143 
144 /**
145  * Gets retry timeout.
146  *
147  * Extracts the time (in seconds) until the expiration of the "retry-after"
148  * time-out in the HTTP message. If the header value is an absolute date, it
149  * is converted relative to the current time.
150  *
151  * @return the time in seconds, zero if the date is overdue or on error.
152  */
153 unsigned vlc_http_msg_get_retry_after(const struct vlc_http_msg *);
154 
155 void vlc_http_msg_get_cookies(const struct vlc_http_msg *,
156  struct vlc_http_cookie_jar_t *,
157  const char *host, const char *path);
159  struct vlc_http_cookie_jar_t *);
160 
161 char *vlc_http_msg_get_basic_realm(const struct vlc_http_msg *);
162 
163 /**
164  * Adds Basic credentials.
165  *
166  * Formats a plain username and password pair using HTTP Basic (RFC7617)
167  * syntax.
168  *
169  * @param proxy true for proxy authentication,
170  * false for origin server authentication
171  * @param username null-terminated username
172  * @param password null-terminated password
173  * @return 0 on success, -1 on out-of-memory (ENOMEM) or if username or
174  * password are invalid (EINVAL).
175  */
176 int vlc_http_msg_add_creds_basic(struct vlc_http_msg *, bool proxy,
177  const char *username, const char *password);
178 
179 
180 /**
181  * Looks up an header field.
182  *
183  * Finds an HTTP header field by (case-insensitive) name inside an HTTP
184  * message header. If the message has more than one matching field, their value
185  * are folded (as permitted by protocol specifications).
186  *
187  * @return header field value (valid until message is destroyed),
188  * or NULL if no fields matched
189  */
190 const char *vlc_http_msg_get_header(const struct vlc_http_msg *,
191  const char *name);
192 
193 /**
194  * Gets response status code.
195  *
196  * @return status code (e.g. 404), or negative if request
197  */
198 int vlc_http_msg_get_status(const struct vlc_http_msg *m);
199 
200 /**
201  * Gets request method.
202  *
203  * @return request method (e.g. "GET"), or NULL if response
204  */
205 const char *vlc_http_msg_get_method(const struct vlc_http_msg *);
206 
207 /**
208  * Gets request scheme.
209  *
210  * @return request scheme (e.g. "https"), or NULL if absent
211  */
212 const char *vlc_http_msg_get_scheme(const struct vlc_http_msg *);
213 
214 /**
215  * Gets request authority.
216  *
217  * @return request authority (e.g. "www.example.com:8080"),
218  * or NULL if response
219  */
220 const char *vlc_http_msg_get_authority(const struct vlc_http_msg *);
221 
222 /**
223  * Gets request absolute path.
224  *
225  * @return request absolute path (e.g. "/index.html"), or NULL if absent
226  */
227 const char *vlc_http_msg_get_path(const struct vlc_http_msg *);
228 
229 /**
230  * Looks up a token in a header field.
231  *
232  * Finds the first occurence of a token within a HTTP field header.
233  *
234  * @param field HTTP header field name
235  * @param token HTTP token name
236  * @return the first byte of the token if found, NULL if not found.
237  */
238 const char *vlc_http_msg_get_token(const struct vlc_http_msg *,
239  const char *field, const char *token);
240 
241 /**
242  * Finds next token.
243  *
244  * Finds the following token in a HTTP header field value.
245  *
246  * @return First character of the following token,
247  * or NULL if there are no further tokens
248  */
249 const char *vlc_http_next_token(const char *);
250 
251 /**
252  * Gets HTTP payload length.
253  *
254  * Determines the total length (in bytes) of the payload associated with the
255  * HTTP message.
256  *
257  * @return byte length, or (uintmax_t)-1 if unknown.
258  */
259 uintmax_t vlc_http_msg_get_size(const struct vlc_http_msg *);
260 
261 /**
262  * Gets next response headers.
263  *
264  * Discards the current response headers and gets the next set of response
265  * headers for the same request. This is intended for HTTP 1xx continuation
266  * responses and for message trailers.
267  *
268  * @param m current response headers (destroyed by the call)
269  *
270  * @return next response headers or NULL on error
271  */
273 
274 /**
275  * Gets final response headers.
276  *
277  * Skips HTTP 1xx continue headers until a final set of response headers is
278  * received. This is a convenience wrapper around vlc_http_msg_iterate() for
279  * use when continuation headers are not useful (e.g. GET or CONNECT).
280  *
281  * @param m current response headers or NULL
282  *
283  * @return the final response headers (m if it was already final),
284  * NULL if the parameter was NULL, or NULL on error
285  */
287 
288 /**
289  * Receives HTTP data.
290  *
291  * Dequeues the next block of data from an HTTP message. If no pending data has
292  * been received, waits until data is received, the stream ends or the
293  * underlying connection fails.
294  *
295  * @return data block
296  * @retval NULL on end-of-stream
297  * @retval vlc_http_error on fatal error
298  */
300 
301 /**
302  * Sends HTTP data.
303  *
304  * Queues the next block of data for an HTTP message payload.
305  *
306  * @note This function takes ownership of the passed data block(s).
307  *
308  * @param b chain of block of data to be sent
309  * @param eos true to indicate the end of the payload
310  * @retval 0 success
311  * @retval -1 fatal error
312  */
313 int vlc_http_msg_write(struct vlc_http_msg *, block_t *b, bool eos);
314 
315 /** @} */
316 
317 /**
318  * \defgroup http_stream Streams
319  * \ingroup http_connmgr
320  *
321  * HTTP request/response streams
322  *
323  * A stream is initiated by a client-side request header. It includes a
324  * final response header, possibly preceded by one or more continuation
325  * response headers. After the response header, a stream usually carries
326  * a response payload.
327  *
328  * A stream may also carry a request payload (this is not supported so far).
329  *
330  * The HTTP stream constitutes the interface between an HTTP connection and
331  * the higher-level HTTP messages layer.
332  * @{
333  */
334 
335 struct vlc_http_stream;
336 
337 /**
338  * Error pointer value
339  *
340  * This is an error value for some HTTP functions that can return NULL in
341  * non-error circumstances. Another return value is necessary to express
342  * error/failure, which this is.
343  * This compares different to NULL and to any valid pointer.
344  *
345  * @warning Dereferencing this pointer is undefined.
346  */
347 extern void *const vlc_http_error;
348 
349 void vlc_http_msg_attach(struct vlc_http_msg *m, struct vlc_http_stream *s);
351 VLC_USED;
352 
353 /** HTTP stream callbacks
354  *
355  * Connection-specific callbacks for stream manipulation
356  */
358 {
359  struct vlc_http_msg *(*read_headers)(struct vlc_http_stream *);
360  ssize_t (*write)(struct vlc_http_stream *, const void *, size_t, bool eos);
361  struct block_t *(*read)(struct vlc_http_stream *);
362  void (*close)(struct vlc_http_stream *, bool abort);
363 };
364 
365 /** HTTP stream */
367 {
368  const struct vlc_http_stream_cbs *cbs;
369 };
370 
371 /**
372  * Reads one message header.
373  *
374  * Reads the next message header of an HTTP stream from the network.
375  * There is always exactly one request header per stream. There is usually
376  * one response header per stream, except for continuation (1xx) headers.
377  *
378  * @warning The caller is responsible for reading headers at appropriate
379  * times as intended by the protocol. Failure to do so may result in protocol
380  * dead lock, and/or (HTTP 1.x) connection failure.
381  */
382 static inline
384 {
385  return s->cbs->read_headers(s);
386 }
387 
388 /**
389  * Write message payload data.
390  *
391  * Writes data as message payload of an HTTP stream.
392  *
393  * @todo Take a block structure rather than a byte array.
394  *
395  * @param base start address of data to write
396  * @param length length in bytes of data to write
397  * @param eos whether this is the last write on the stream
398  * @retval len success
399  * @retval -1 error
400  */
401 static inline ssize_t vlc_http_stream_write(struct vlc_http_stream *s,
402  const void *base, size_t length,
403  bool eos)
404 {
405  return s->cbs->write(s, base, length, eos);
406 }
407 
408 /**
409  * Reads message payload data.
410  *
411  * Reads the next block of data from the message payload of an HTTP stream.
412  *
413  * @return a block of data (use block_Release() to free it)
414  * @retval NULL The end of the stream was reached.
415  * @retval vlc_http_error The stream encountered a fatal error.
416  */
417 static inline struct block_t *vlc_http_stream_read(struct vlc_http_stream *s)
418 {
419  return s->cbs->read(s);
420 }
421 
422 /**
423  * Closes an HTTP stream.
424  *
425  * Releases all resources associated or held by an HTTP stream. Any unread
426  * header or data is discarded.
427  */
428 static inline void vlc_http_stream_close(struct vlc_http_stream *s, bool abort)
429 {
430  s->cbs->close(s, abort);
431 }
432 
433 /** @} */
434 
435 /**
436  * Formats an HTTP 1.1 message header.
437  *
438  * Formats an message header in HTTP 1.x format, using HTTP version 1.1.
439  *
440  * @param m message to format/serialize
441  * @param lenp location to write the length of the formatted message in bytes
442  * [OUT]
443  * @param proxied whether the message is meant for sending to a proxy rather
444  * than an origin (only relevant for requests)
445  * @param chunked whether to append a chunked transfer encoding header line
446  * @return A heap-allocated nul-terminated string or *lenp bytes,
447  * or NULL on error
448  */
449 char *vlc_http_msg_format(const struct vlc_http_msg *m, size_t *restrict lenp,
450  bool proxied, bool chunked) VLC_USED;
451 
452 /**
453  * Parses an HTTP 1.1 message header.
454  */
455 struct vlc_http_msg *vlc_http_msg_headers(const char *msg) VLC_USED;
456 
457 struct vlc_h2_frame;
458 
459 /**
460  * Formats an HTTP 2.0 HEADER frame.
461  */
462 struct vlc_h2_frame *vlc_http_msg_h2_frame(const struct vlc_http_msg *m,
463  uint_fast32_t stream_id, bool eos);
464 
465 /**
466  * Parses an HTTP 2.0 header table.
467  */
469  const char *const headers[][2]);
vlc_http_msg_get_retry_after
unsigned vlc_http_msg_get_retry_after(const struct vlc_http_msg *m)
Gets retry timeout.
Definition: message.c:882
count
size_t count
Definition: core.c:401
vlc_http_msg_format
char * vlc_http_msg_format(const struct vlc_http_msg *m, size_t *restrict lenp, bool proxied, bool chunked) VLC_USED
Formats an HTTP 1.1 message header.
Definition: message.c:331
vlc_http_msg_get_path
const char * vlc_http_msg_get_path(const struct vlc_http_msg *m)
Gets request absolute path.
Definition: message.c:188
vlc_http_msg_get_basic_realm
char * vlc_http_msg_get_basic_realm(const struct vlc_http_msg *m)
Definition: message.c:987
vlc_memstream
In-memory stream object.
Definition: vlc_memstream.h:41
block_ChainRelease
static void block_ChainRelease(block_t *p_block)
Definition: vlc_block.h:358
vlc_http_error_loc
static const char vlc_http_error_loc
Definition: message.c:55
vlc_http_istoken
static int vlc_http_istoken(int c)
Definition: message.c:585
vlc_http.h
strcasecmp
int strcasecmp(const char *, const char *)
vlc_http_token_length
static size_t vlc_http_token_length(const char *str)
Definition: message.c:600
vlc_http_authority
char * vlc_http_authority(const char *host, unsigned port)
Formats an authority.
Definition: message.c:573
unlikely
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:227
vlc_http_msg_h2_frame
struct vlc_h2_frame * vlc_http_msg_h2_frame(const struct vlc_http_msg *m, uint_fast32_t stream_id, bool eos)
Formats an HTTP 2.0 HEADER frame.
Definition: message.c:425
vlc_http_stream::cbs
const struct vlc_http_stream_cbs * cbs
Definition: message.h:368
vlc_common.h
vlc_http_stream_read_headers
static struct vlc_http_msg * vlc_http_stream_read_headers(struct vlc_http_stream *s)
Reads one message header.
Definition: message.h:383
vlc_http_msg_get_method
const char * vlc_http_msg_get_method(const struct vlc_http_msg *m)
Gets request method.
Definition: message.c:173
vlc_http_msg_format
char * vlc_http_msg_format(const struct vlc_http_msg *m, size_t *restrict lenp, bool proxied, bool chunked)
Formats an HTTP 1.1 message header.
Definition: message.c:331
block_t::i_buffer
size_t i_buffer
Payload length.
Definition: vlc_block.h:122
vlc_http_msg_h2_headers
struct vlc_http_msg * vlc_http_msg_h2_headers(unsigned n, const char *const hdrs[][2])
Parses an HTTP 2.0 header table.
Definition: message.c:487
vlc_http_msg_add_creds_basic
int vlc_http_msg_add_creds_basic(struct vlc_http_msg *m, bool proxy, const char *username, const char *password)
Adds Basic credentials.
Definition: message.c:1005
gmtime_r
struct tm * gmtime_r(const time_t *, struct tm *)
vlc_http_msg_destroy
void vlc_http_msg_destroy(struct vlc_http_msg *m)
Destroys an HTTP message.
Definition: message.c:193
vlc_http_msg_h2_headers
struct vlc_http_msg * vlc_http_msg_h2_headers(unsigned count, const char *const headers[][2])
Parses an HTTP 2.0 header table.
Definition: message.c:487
vlc_http_msg::count
unsigned count
Definition: message.c:68
vlc_http_comment_length
static size_t vlc_http_comment_length(const char *str)
Definition: message.c:715
vlc_http_msg_iterate
struct vlc_http_msg * vlc_http_msg_iterate(struct vlc_http_msg *m)
Gets next response headers.
Definition: message.c:265
vlc_http_stream_cbs::read_headers
struct vlc_http_msg *(* read_headers)(struct vlc_http_stream *)
Definition: message.h:359
vlc_http_stream_read
static struct block_t * vlc_http_stream_read(struct vlc_http_stream *s)
Reads message payload data.
Definition: message.h:417
vlc_memstream_puts
int() vlc_memstream_puts(struct vlc_memstream *ms, const char *str)
Appends a nul-terminated string to a byte stream.
Definition: memstream.c:156
vlc_http_get_token
static const char * vlc_http_get_token(const char *value, const char *token)
Definition: message.c:652
vlc_http_quoted_length
static size_t vlc_http_quoted_length(const char *str)
Definition: message.c:609
vlc_http_cookies_fetch
char * vlc_http_cookies_fetch(vlc_http_cookie_jar_t *p_jar, bool secure, const char *host, const char *path)
Returns a cookie value that match the given URL.
Definition: httpcookies.c:351
vlc_memstream_open
int vlc_memstream_open(struct vlc_memstream *ms)
Initializes a byte stream object.
Definition: memstream.c:105
vlc_http_next_token
const char * vlc_http_next_token(const char *value)
Finds next token.
Definition: message.c:642
vlc_http_msg_add_agent
int vlc_http_msg_add_agent(struct vlc_http_msg *m, const char *str)
Sets the agent field.
Definition: message.c:783
vlc_memstream_close
int vlc_memstream_close(struct vlc_memstream *ms)
Closes a byte stream object.
Definition: memstream.c:120
vlc_http_stream_write
static ssize_t vlc_http_stream_write(struct vlc_http_stream *s, const void *base, size_t length, bool eos)
Write message payload data.
Definition: message.h:401
vlc_http_msg_add_header
int vlc_http_msg_add_header(struct vlc_http_msg *m, const char *name, const char *fmt,...)
Definition: message.c:144
asprintf
int asprintf(char **, const char *,...)
vlc_http_stream_cbs
HTTP stream callbacks.
Definition: message.h:357
vlc_http_msg_h2_frame
struct vlc_h2_frame * vlc_http_msg_h2_frame(const struct vlc_http_msg *m, uint_fast32_t stream_id, bool eos)
Formats an HTTP 2.0 HEADER frame.
Definition: message.c:425
vlc_http_msg_add_header
int vlc_http_msg_add_header(struct vlc_http_msg *, const char *name, const char *fmt,...) VLC_FORMAT(3
Formats a header field.
strndup
char * strndup(const char *, size_t)
vlc_http_msg_add_atime
int vlc_http_msg_add_atime(struct vlc_http_msg *m)
Adds a Date header field.
Definition: message.c:826
vlc_http_msg_get_atime
time_t vlc_http_msg_get_atime(const struct vlc_http_msg *m)
Gets message date.
Definition: message.c:872
vlc_http_cookies_store
bool vlc_http_cookies_store(vlc_http_cookie_jar_t *p_jar, const char *cookies, const char *host, const char *path)
Parse a value of an incoming Set-Cookie header and append the cookie to the cookie jar if appropriate...
Definition: httpcookies.c:296
vlc_http_msg::payload
struct vlc_http_stream * payload
Definition: message.c:69
vlc_http_msg_get_cookies
void vlc_http_msg_get_cookies(const struct vlc_http_msg *m, vlc_http_cookie_jar_t *jar, const char *host, const char *path)
Definition: message.c:934
vlc_http_days
static const char vlc_http_days[7][4]
Definition: message.c:803
vlc_http_msg_get_agent
const char * vlc_http_msg_get_agent(const struct vlc_http_msg *m)
Gets the agent field.
Definition: message.c:795
block_t::p_next
block_t * p_next
Definition: vlc_block.h:119
vlc_memstream_printf
int vlc_memstream_printf(struct vlc_memstream *ms, const char *fmt,...)
Appends a formatted string to a byte stream.
Definition: memstream.c:194
vlc_http_msg_get_scheme
const char * vlc_http_msg_get_scheme(const struct vlc_http_msg *m)
Gets request scheme.
Definition: message.c:178
vlc_memstream::stream
FILE * stream
Definition: vlc_memstream.h:45
vlc_http_msg_get_initial
struct vlc_http_msg * vlc_http_msg_get_initial(struct vlc_http_stream *s)
Definition: message.c:276
message.h
vlc_http_req_create
struct vlc_http_msg * vlc_http_req_create(const char *method, const char *scheme, const char *authority, const char *path)
Creates an HTTP request.
Definition: message.c:213
vlc_http_msg::scheme
char * scheme
Definition: message.c:64
vlc_http_msg_get_final
struct vlc_http_msg * vlc_http_msg_get_final(struct vlc_http_msg *m)
Gets final response headers.
Definition: message.c:284
vlc_memstream.h
vlc_http_mktime
static time_t vlc_http_mktime(const char *str)
Definition: message.c:834
vlc_strings.h
vlc_http_msg_get_token
const char * vlc_http_msg_get_token(const struct vlc_http_msg *msg, const char *field, const char *token)
Looks up a token in a header field.
Definition: message.c:709
vlc_b64_encode_binary
char * vlc_b64_encode_binary(const void *src, size_t length)
Base64 encoding.
Definition: strings.c:360
vlc_http_msg::status
short status
Definition: message.c:62
vlc_http_months
static const char vlc_http_months[12][4]
Definition: message.c:806
vlc_http_stream_cbs::write
ssize_t(* write)(struct vlc_http_stream *, const void *, size_t, bool eos)
Definition: message.h:360
VLC_H2_DEFAULT_MAX_FRAME
#define VLC_H2_DEFAULT_MAX_FRAME
Definition: h2frame.h:98
vlc_http_is_token
static bool vlc_http_is_token(const char *)
Definition: message.c:636
vlc_http_msg::headers
char *(* headers)[2]
Definition: message.c:67
max_align_t
Definition: vlc_fixups.h:136
vlc_http_msg_headers
struct vlc_http_msg * vlc_http_msg_headers(const char *msg) VLC_USED
Parses an HTTP 1.1 message header.
Definition: message.c:366
vlc_http_stream
HTTP stream.
Definition: message.h:366
vlc_http_error
void *const vlc_http_error
Error pointer value.
Definition: message.c:57
VLC_FORMAT
#define VLC_FORMAT(x, y)
String format function annotation.
Definition: vlc_common.h:141
vlc_http_msg_get_time
time_t vlc_http_msg_get_time(const struct vlc_http_msg *m, const char *name)
Parses a timestamp header field.
Definition: message.c:864
vlc_http_stream_cbs::close
void(* close)(struct vlc_http_stream *, bool abort)
Definition: message.h:362
vlc_http_msg_headers
struct vlc_http_msg * vlc_http_msg_headers(const char *msg)
Parses an HTTP 1.1 message header.
Definition: message.c:366
vlc_http_msg_get_authority
const char * vlc_http_msg_get_authority(const struct vlc_http_msg *m)
Gets request authority.
Definition: message.c:183
vlc_http_msg_attach
void vlc_http_msg_attach(struct vlc_http_msg *m, struct vlc_http_stream *s)
Definition: message.c:259
vlc_http_get_token_value
static char * vlc_http_get_token_value(const char *value, const char *token)
Definition: message.c:668
strdup
char * strdup(const char *)
vlc_http_msg_vadd_header
static int vlc_http_msg_vadd_header(struct vlc_http_msg *m, const char *name, const char *fmt, va_list ap)
Definition: message.c:70
VLC_USED
#define VLC_USED
Definition: fourcc_gen.c:32
vlc_h2_frame
Definition: h2frame.h:30
vlc_block.h
name
const char name[16]
Definition: httpd.c:1268
vlc_http_msg::method
char * method
Definition: message.c:63
vlc_http_msg::path
char * path
Definition: message.c:66
vlc_http_resp_create
struct vlc_http_msg * vlc_http_resp_create(unsigned status)
Creates an HTTP response.
Definition: message.c:241
vlc_http_stream_cbs::read
struct block_t *(* read)(struct vlc_http_stream *)
Definition: message.h:361
vlc_http_msg_get_mtime
time_t vlc_http_msg_get_mtime(const struct vlc_http_msg *m)
Gets resource date.
Definition: message.c:877
vlc_h2_frame_headers
struct vlc_h2_frame * vlc_h2_frame_headers(uint_fast32_t stream_id, uint_fast32_t mtu, bool eos, unsigned count, const char *const headers[][2])
Definition: h2frame.c:155
timegm
time_t timegm(struct tm *)
vlc_http_is_agent
static bool vlc_http_is_agent(const char *s)
Definition: message.c:745
vlc_http_msg_get_header
const char * vlc_http_msg_get_header(const struct vlc_http_msg *m, const char *name)
Looks up an header field.
Definition: message.c:156
vlc_http_msg_get_status
int vlc_http_msg_get_status(const struct vlc_http_msg *m)
Gets response status code.
Definition: message.c:168
block_t::p_buffer
uint8_t * p_buffer
Payload start.
Definition: vlc_block.h:121
vlc_http_msg_read
block_t * vlc_http_msg_read(struct vlc_http_msg *m)
Receives HTTP data.
Definition: message.c:291
vlc_http_msg_add_time
int vlc_http_msg_add_time(struct vlc_http_msg *m, const char *hname, const time_t *t)
Adds a timestamp header field.
Definition: message.c:811
vlc_http_msg_find_header
static ssize_t vlc_http_msg_find_header(const struct vlc_http_msg *m, const char *name)
Definition: message.c:61
vlc_alloc
static void * vlc_alloc(size_t count, size_t size)
Definition: vlc_common.h:1144
vlc_http_msg_get_size
uintmax_t vlc_http_msg_get_size(const struct vlc_http_msg *m)
Gets HTTP payload length.
Definition: message.c:905
vlc_http_msg
Definition: message.c:42
block_Release
void block_Release(block_t *block)
Releases a block.
Definition: block.c:135
vlc_http_msg::authority
char * authority
Definition: message.c:65
h2frame.h
block_t
Definition: vlc_block.h:117
vasprintf
int vasprintf(char **, const char *, va_list)
vlc_http_isctext
static int vlc_http_isctext(int c)
Definition: message.c:593
vlc_http_msg_write
int vlc_http_msg_write(struct vlc_http_msg *m, block_t *block, bool eos)
Sends HTTP data.
Definition: message.c:299
vlc_http_msg_add_cookies
int vlc_http_msg_add_cookies(struct vlc_http_msg *m, vlc_http_cookie_jar_t *jar)
Definition: message.c:946
p
#define p(t)
vlc_http_stream_close
static void vlc_http_stream_close(struct vlc_http_stream *s, bool abort)
Closes an HTTP stream.
Definition: message.h:428