summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/http.h
blob: 3cfc888a45dcfba59fe810d9629a98e38cd6bd62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _GPXE_HTTP_H
#define _GPXE_HTTP_H

/** @file
 *
 * Hyper Text Transport Protocol
 *
 */

#include <stdint.h>
#include <gpxe/tcp.h>
#include <gpxe/async.h>
#include <gpxe/linebuf.h>
#include <gpxe/uri.h>

/** HTTP default port */
#define HTTP_PORT 80

/** HTTP receive state */
enum http_rx_state {
	HTTP_RX_RESPONSE = 0,
	HTTP_RX_HEADER,
	HTTP_RX_DATA,
	HTTP_RX_DEAD,
};

/**
 * An HTTP request
 *
 */
struct http_request {
	/** URI being fetched */
	struct uri *uri;
	/** Data buffer to fill */
	struct buffer *buffer;
	/** Asynchronous operation */
	struct async async;

	/** HTTP response code */
	unsigned int response;
	/** HTTP Content-Length */
	size_t content_length;

	/** Server address */
	struct sockaddr server;
	/** TCP application for this request */
	struct tcp_application tcp;
	/** Number of bytes already sent */
	size_t tx_offset;
	/** RX state */
	enum http_rx_state rx_state;
	/** Line buffer for received header lines */
	struct line_buffer linebuf;
};

extern int http_get ( struct uri *uri, struct buffer *buffer,
		      struct async *parent );

#endif /* _GPXE_HTTP_H */