1
- // libhttp - A HTTP client and server library.
1
+ /*
2
+ * libhttp - A HTTP (RFC 2616) library for C.
3
+ */
2
4
3
5
#ifndef http_h
4
6
#define http_h
@@ -12,54 +14,60 @@ typedef struct http_message_s http_message;
12
14
typedef int (* http_stream_cb )(http_stream * stream , void * context );
13
15
14
16
enum http_error_codes {
15
- HTTP_ENOTIMPL // Not yet implemented.
17
+ HTTP_ENOTIMPL /* Not yet implemented. */
16
18
};
17
19
18
20
enum http_message_type {
19
21
HTTP_MESSAGE_REQUEST ,
20
22
HTTP_MESSAGE_RESPONSE
21
23
};
22
24
23
- // Streams provide an interface for writing data to the socket
24
- // bound to a session. They are responsible for handling any
25
- // encoding/decoding of the data. Data will be written or read from
26
- // buffers supplied and returning number of bytes actually transferred.
27
- // Note: these methods may or may not block depending on the
28
- // underlying socket's mode.
25
+ /* Streams provide an interface for writing data to the socket
26
+ * bound to a session. They are responsible for handling any
27
+ * encoding/decoding of the data. Data will be written or read from
28
+ * buffers supplied and returning number of bytes actually transferred.
29
+ * Note: these methods may or may not block depending on the
30
+ * underlying socket's mode.
31
+ */
29
32
size_t http_stream_read (char * buffer , size_t size );
30
33
size_t http_stream_write (const char * buffer , size_t size );
31
34
32
- // A session represents a connection between a client and the server.
33
- // Create a socket connected to the server or accept incoming client
34
- // from listening socket. Initialize a new HTTP session using this socket.
35
- // Closing the session also closes the underlying socket.
35
+ /* A session represents a connection between a client and the server.
36
+ * Create a socket connected to the server or accept incoming client
37
+ * from listening socket. Initialize a new HTTP session using this socket.
38
+ * Closing the session also closes the underlying socket.
39
+ */
36
40
http_session * http_session_init (int sockfd );
37
41
void http_session_close (http_session * session );
38
42
39
- // Parsing of messages arriving from a session.
40
- // Clients will parse responses while servers parse requests.
43
+ /* Parsing of messages arriving from a session.
44
+ * Clients will parse responses while servers parse requests.
45
+ */
41
46
http_message * http_session_parse_request (http_session * session );
42
47
http_message * http_session_parse_response (http_session * session );
43
48
44
- // Compose a new message for sending with a session.
45
- // Clients will compose requests while servers compose responses.
49
+ /* Compose a new message for sending with a session.
50
+ * Clients will compose requests while servers compose responses.
51
+ */
46
52
http_message * http_request (const char * method , const char * uri );
47
53
http_message * http_response (int status_code , const char * reason_phrase );
48
54
49
- // Append a new header to the message if a field with
50
- // this name does not yet exist. If it already exists then
51
- // the new value will be appended follow RFC2616 4.2 guidelines.
55
+ /* Append a new header to the message if a field with
56
+ * this name does not yet exist. If it already exists then
57
+ * the new value will be appended follow RFC2616 4.2 guidelines.
58
+ */
52
59
void http_message_append_header (http_message * msg , const char * name , const char * value );
53
60
54
- // Type of message: request or response.
61
+ /* Type of message: request or response. */
55
62
int http_message_get_type (http_message * msg );
56
63
57
- // Set a stream callback for reading or writing the message body.
58
- // A parsed (incoming) message will read while a composed (outgoing)
59
- // message will be writing.
64
+ /* Set a stream callback for reading or writing the message body.
65
+ * A parsed (incoming) message will read while a composed (outgoing)
66
+ * message will be writing.
67
+ */
60
68
void http_message_set_body_cb (http_message * msg , http_stream_cb cb , void * context );
61
69
62
- // Send a fully composed message with a session.
70
+ /* Send a fully composed message with a session. */
63
71
int http_session_send_message (http_session * session , const http_message * msg );
64
72
65
73
#endif
0 commit comments