source: mainline/uspace/lib/http/http.h@ 3ce68b7

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3ce68b7 was 3ce68b7, checked in by Martin Sucha <sucha14@…>, 12 years ago

libhttp: receive headers correctly

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Copyright (c) 2013 Martin Sucha
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup http
30 * @{
31 */
32/**
33 * @file
34 */
35
36#ifndef HTTP_HTTP_H_
37#define HTTP_HTTP_H_
38
39#include <net/socket.h>
40#include <adt/list.h>
41#include <inet/addr.h>
42
43#include "receive-buffer.h"
44
45typedef struct {
46 char *host;
47 uint16_t port;
48 inet_addr_t addr;
49
50 bool connected;
51 int conn_sd;
52
53 size_t buffer_size;
54 receive_buffer_t recv_buffer;
55} http_t;
56
57typedef struct {
58 uint8_t minor;
59 uint8_t major;
60} http_version_t;
61
62typedef struct {
63 link_t link;
64 char *name;
65 char *value;
66} http_header_t;
67
68typedef struct {
69 char *method;
70 char *path;
71 list_t headers;
72} http_request_t;
73
74typedef struct {
75 http_version_t version;
76 uint16_t status;
77 char *message;
78 list_t headers;
79} http_response_t;
80
81extern http_t *http_create(const char *, uint16_t);
82extern int http_connect(http_t *);
83
84extern void http_header_init(http_header_t *);
85extern http_header_t *http_header_create(const char *, const char *);
86extern int http_header_receive_name(receive_buffer_t *, char **);
87extern int http_header_receive_value(receive_buffer_t *, char **);
88extern int http_header_receive(receive_buffer_t *, http_header_t *);
89extern void http_header_normalize_value(char *);
90ssize_t http_header_encode(http_header_t *, char *, size_t);
91extern void http_header_destroy(http_header_t *);
92
93extern http_request_t *http_request_create(const char *, const char *);
94extern void http_request_destroy(http_request_t *);
95extern int http_request_format(http_request_t *, char **, size_t *);
96extern int http_send_request(http_t *, http_request_t *);
97extern int http_parse_status(const char *, http_version_t *, uint16_t *,
98 char **);
99extern int http_receive_response(http_t *, http_response_t **);
100extern int http_receive_body(http_t *, void *, size_t);
101extern void http_response_destroy(http_response_t *);
102extern int http_close(http_t *);
103extern void http_destroy(http_t *);
104
105#endif
106
107/** @}
108 */
Note: See TracBrowser for help on using the repository browser.