2006-08-11 14:13:02 +00:00
|
|
|
#ifndef _GPXE_HTTP_H
|
|
|
|
|
#define _GPXE_HTTP_H
|
|
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* Hyper Text Transport Protocol
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <gpxe/tcp.h>
|
|
|
|
|
#include <gpxe/async.h>
|
2007-01-12 19:18:13 +00:00
|
|
|
#include <gpxe/linebuf.h>
|
2006-08-11 14:13:02 +00:00
|
|
|
|
|
|
|
|
/** HTTP default port */
|
|
|
|
|
#define HTTP_PORT 80
|
|
|
|
|
|
2007-01-12 19:18:13 +00:00
|
|
|
/** HTTP receive state */
|
|
|
|
|
enum http_rx_state {
|
|
|
|
|
HTTP_RX_RESPONSE = 0,
|
|
|
|
|
HTTP_RX_HEADER,
|
|
|
|
|
HTTP_RX_DATA,
|
|
|
|
|
HTTP_RX_DEAD,
|
2006-08-11 14:13:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2007-01-12 19:18:13 +00:00
|
|
|
* An HTTP request
|
2006-08-11 14:13:02 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
struct http_request {
|
2006-12-27 23:09:46 +00:00
|
|
|
/** Server address */
|
|
|
|
|
struct sockaddr_tcpip server;
|
2007-01-12 19:18:13 +00:00
|
|
|
/** Server host name */
|
|
|
|
|
const char *hostname;
|
|
|
|
|
/** Filename */
|
|
|
|
|
const char *filename;
|
|
|
|
|
/** Data buffer to fill */
|
|
|
|
|
struct buffer *buffer;
|
|
|
|
|
|
|
|
|
|
/** HTTP response code */
|
|
|
|
|
unsigned int response;
|
|
|
|
|
/** HTTP Content-Length */
|
|
|
|
|
size_t content_length;
|
|
|
|
|
|
|
|
|
|
/** 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;
|
|
|
|
|
|
2006-12-27 23:09:46 +00:00
|
|
|
/** TCP application for this request */
|
|
|
|
|
struct tcp_application tcp;
|
2006-08-11 14:13:02 +00:00
|
|
|
/** Asynchronous operation */
|
|
|
|
|
struct async_operation aop;
|
|
|
|
|
};
|
|
|
|
|
|
2007-01-12 19:18:13 +00:00
|
|
|
extern struct async_operation * http_get ( struct http_request *http );
|
2006-08-11 14:13:02 +00:00
|
|
|
|
|
|
|
|
#endif /* _GPXE_HTTP_H */
|