wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Functions
httpread.c File Reference

httpread - Manage reading file(s) from HTTP/TCP socket Author: Ted Merrill More...

#include "includes.h"
#include "common.h"
#include "eloop.h"
#include "httpread.h"

Data Structures

struct  httpread
 

Macros

#define HTTPREAD_READBUF_SIZE   1024 /* read in chunks of this size */
 
#define HTTPREAD_HEADER_MAX_SIZE   4096 /* max allowed for headers */
 
#define HTTPREAD_BODYBUF_DELTA   4096 /* increase allocation by this */
 

Functions

void httpread_destroy (struct httpread *h)
 
struct httpreadhttpread_create (int sd, void(*cb)(struct httpread *handle, void *cookie, enum httpread_event e), void *cookie, int max_bytes, int timeout_seconds)
 
enum httpread_hdr_type httpread_hdr_type_get (struct httpread *h)
 
char * httpread_uri_get (struct httpread *h)
 
int httpread_reply_code_get (struct httpread *h)
 
int httpread_length_get (struct httpread *h)
 
void * httpread_data_get (struct httpread *h)
 
char * httpread_hdr_get (struct httpread *h)
 
char * httpread_hdr_line_get (struct httpread *h, const char *tag)
 

Detailed Description

httpread - Manage reading file(s) from HTTP/TCP socket Author: Ted Merrill

The files are buffered via internal callbacks from eloop, then presented to an application callback routine when completely read into memory. May also be used if no file is expected but just to get the header, including HTTP replies (e.g. HTTP/1.1 200 OK etc.).

This does not attempt to be an optimally efficient implementation, but does attempt to be of reasonably small size and memory consumption; assuming that only small files are to be read. A maximum file size is provided by application and enforced.

It is assumed that the application does not expect any of the following: – transfer encoding other than chunked – trailer fields It is assumed that, even if the other side requested that the connection be kept open, that we will close it (thus HTTP messages sent by application should have the connection closed field); this is allowed by HTTP/1.1 and simplifies things for us.

Other limitations: – HTTP header may not exceed a hard-coded size.

Notes: This code would be massively simpler without some of the new features of HTTP/1.1, especially chunked data.