Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

libhttp.h File Reference

http protocol implementation, client only More...

Go to the source code of this file.

Data Structures

struct  prod_cons_t
 Structure between the engine and the libhttp_thread modules. More...

struct  prod_cons_t::http_batton_t
 other fields that may be moved to a void* More...

struct  range_t
 Structure defining a byte range used by HTTP Range field. More...

struct  cookielist_t
 Structure defining list storing the cookies obtained since now. More...


Functions

prod_cons_tnew_prodcons ()
 allocates the structure

void delete_prodcons (struct prod_cons_t *p)
 deletes the structure

void set_useragent (const char *ua)
 Set the User Agent to be used for HTTP request.

void set_proxyaddr (const char *addr)
 Set the proxy address to be used for HTTP request.

void set_proxyauth (const char *pa)
 Set username and password to authenticate with a proxy server.

char * buildreqheader (const char *host, const char *useragent, const char *referrer, const char *proxyauth, struct cookielist_t *cl, range_t range, char **reqheaderp)
 Build a Request-Header using the parameter passed as argument.

char * httpget (const char *server, const char *file, const char *reqheader, struct prod_cons_t *pc, char **headerp, char **bodyp)
 Perform an HTTP GET request to the specified server.

cookielist_taddcookies (const char *header, struct cookielist_t *cl)
 Add all the cookies received to a list.

char * getpage (const char *host, const char *fileformat, char **refp, int updateref, struct cookielist_t **clp,...)
 Performs a download of a web page like a browser would do.

char * getpage_hidepassw (const char *host, const char *fileformat, char **refp, int updateref, struct cookielist_t **clp,...)
 Retrieve a web page hiding the password from the log.

char * getpage_range (const char *host, const char *fileformat, range_t range, char **refp, int updateref, struct cookielist_t **clp,...)
 Retrieve only a part of a web page.

int httpget_thread (const char *file, const char *reqheader, char **headerp, struct prod_cons_t *p)
 passing le baton, plus support ot trucate connesstion setting p->stop flag

void * getpage_thread (void *x)
 use this with pthread_create, x is a struct prod_cons_t *


Detailed Description

http protocol implementation, client only

Author:
Alessio Caprari   <sorry guy>

Definition in file libhttp.h.


Function Documentation

struct cookielist_t* addcookies const char *  header,
struct cookielist_t cl
 

Add all the cookies received to a list.

Parameters:
header A string representing the header where to find cookies.
cl A pointer to the head of a list of cookies.
Returns:
A pointer to the new head of the list of cookies.

char* buildreqheader const char *  host,
const char *  useragent,
const char *  referrer,
const char *  proxyauth,
struct cookielist_t cl,
range_t  range,
char **  reqheaderp
 

Build a Request-Header using the parameter passed as argument.

The needed memory to store all the headers is automatically allocated. Use NULL to avoid the use of optional fields.

Parameters:
host The value of Host field (mandatory)
useragent The value of User-Agent field (optional)
referrer The value of Referer field (optional)
proxyauth The value of Proxy-Authorization field (optional)
cl Pointer to the head of a list of cookies to be included (optional)
range Byte range for Range field (optional), use range.first > range.last to require the full page
reqheaderp The address of a string which will contain all the Request-Header
Returns:
A pointer to the Request-Header or NULL if an error occourred.

void delete_prodcons struct prod_cons_t p  ) 
 

deletes the structure

char* getpage const char *  host,
const char *  fileformat,
char **  refp,
int  updateref,
struct cookielist_t **  clp,
  ...
 

Performs a download of a web page like a browser would do.

Retrieve a web page from the server specified. It allow to specify the UserAgent, the cookies the Referer field for that page. For the file name of the web page, it accept a string format like printf does followed by the necessary arguments.

Parameters:
host the host name of the server (mandatory)
fileformat the name of the file to retrieve with the same format of the one for printf
refp a pointer to a Refer field to send to the server, could be NULL or point to NULL
updateref if non-zero, indicates that refp parameter must be updated with the URL of the file retrieved
clp a pointer to a list of cookie to be sent to the server, could be NULL or point to NULL
... parameters to be substituited in the string format for the file
Returns:
a pointer to the body of the page downloaded or NULL if an error occours

char* getpage_hidepassw const char *  host,
const char *  fileformat,
char **  refp,
int  updateref,
struct cookielist_t **  clp,
  ...
 

Retrieve a web page hiding the password from the log.

See also:
getpage()

char* getpage_range const char *  host,
const char *  fileformat,
range_t  range,
char **  refp,
int  updateref,
struct cookielist_t **  clp,
  ...
 

Retrieve only a part of a web page.

Parameters:
range The byte range to be requested
See also:
getpage()

void* getpage_thread void *  x  ) 
 

use this with pthread_create, x is a struct prod_cons_t *

char* httpget const char *  server,
const char *  file,
const char *  reqheader,
struct prod_cons_t pc,
char **  headerp,
char **  bodyp
 

Perform an HTTP GET request to the specified server.

Perform an HTTP GET request for the specified file using all the Request-Header passed as argument. The function will read the response from the server and will allocate the necessary memory to store it, then the message body will be separed from the trailing headers and both will be returned using the pointers passed as argument.

Parameters:
server The server which the connection will go.
file The file to be requested to the server.
reqheader A string containing all the Request-Header to be sent to the server.
pc A pointer to the structure containing fields to communicate with other threads
headerp The address of a string which will contain all the Entity-Header.
bodyp The address of a string which will contain the message body.
Returns:
A pointer to the body string or NULL if an error occourred.

int httpget_thread const char *  file,
const char *  reqheader,
char **  headerp,
struct prod_cons_t p
 

passing le baton, plus support ot trucate connesstion setting p->stop flag

struct prod_cons_t* new_prodcons  ) 
 

allocates the structure

void set_proxyaddr const char *  addr  ) 
 

Set the proxy address to be used for HTTP request.

Parameters:
addr The new proxy address.

void set_proxyauth const char *  pa  ) 
 

Set username and password to authenticate with a proxy server.

Parameters:
addr The username and password separed by a colon.

void set_useragent const char *  ua  ) 
 

Set the User Agent to be used for HTTP request.

Parameters:
ua The new User Agent name.


Generated on Wed May 5 15:48:04 2004 for LiberoPOPs by doxygen 1.3.6-20040222