LIBRHTTPR(3) librhttpr 0.0 LIBRHTTPR(3)
01 17 2000
NAME
librhttpr - "http request-response" Library
DESCRIPTION
The http request-response Library provides a simple API to make http
requests and get the responses.
SYNOPSIS
#include <librhttpr.h>
REQUEST BUILDER ROUTINES
t_httprq *rhttpr_init_rq();
int rhttpr_raw2rqdata(t_httprq *rq,char *raw_data);
int rhttpr_list2rqdata(t_httprq *rq,t_list *l);
void rhttpr_rq_set_proxy(t_httprq *rq,char *proxy);
void rhttpr_rq_set_proxy_port(t_httprq *rq,int port);
void rhttpr_rq_set_proxy_user(t_httprq *rq,char *user);
void rhttpr_rq_set_proxy_passwd(t_httprq *rq,char *passwd);
void rhttpr_rq_set_user_agent(t_httprq *rq,char *user_agent);
void rhttpr_rq_set_host(t_httprq *rq,char *host);
void rhttpr_rq_set_port(t_httprq *rq,int port);
void rhttpr_rq_set_referer(t_httprq *rq,char *referer);
void rhttpr_rq_set_cookie(t_httprq *rq,char *cookie);
void rhttpr_rq_set_method(t_httprq *rq,int method);
void rhttpr_rq_set_action(t_httprq *rq,char *action);
void rhttpr_rq_set_contentype(t_httprq *rq,char *contentype);
t_httprs *rhttpr_mk_rq(t_httprq *rq);
REPONSE DEALING ROUTINES
char *rhttpr_rs_get_version(t_httprs *rs);
- 1 - Formatted: October 25, 2025
LIBRHTTPR(3) librhttpr 0.0 LIBRHTTPR(3)
01 17 2000
int rhttpr_rs_get_val_ret(t_httprs *rs);
char *rhttpr_rs_get_msg_ret(t_httprs *rs);
int rhttpr_rs_get_con_len(t_httprs *rs);
char *rhttpr_rs_get_con_typ(t_httprs *rs);
char *rhttpr_rs_get_server(t_httprs *rs);
char *rhttpr_rs_get_date(t_httprs *rs);
char *rhttpr_rs_get_last_modif(t_httprs *rs);
char *rhttpr_rs_get_data(t_httprs *rs);
int rhttpr_rs_get_next_field(t_httprs *rs,char **name,char **val);
DESTROY STRUCTURE ROUTINES
void rhttpr_free_rq(t_httprq *rq);
void rhttpr_free_rs(t_httprs *rs);
STRUCTURE CONTENT
typedef struct s_rhttprq {
char *proxy;
int proxy_port;
char *proxy_user;
char *proxy_passwd;
char *user_agent;
char *host;
int port;
int method;
char *referer;
char *cookie;
char *action;
char *data;
int data_len;
char *auth_string;
char *contentype; } t_httprq;
typedef struct s_list {
struct s_list *next;
char *name;
char *val; } t_list;
typedef struct s_httprs {
char *version;
int val_ret;
- 2 - Formatted: October 25, 2025
LIBRHTTPR(3) librhttpr 0.0 LIBRHTTPR(3)
01 17 2000
char *msg_ret;
int content_length;
char *content_type;
char *server;
char *date;
char *last_modif;
char *data;
t_list *fl;
t_list *cur; } t_httprs;
REQUEST BUILDER ROUTINES
rhttpr_init_rq() returns a allocated pointer to the request structure
and sets some fields to default values:
field default value user_agent: flav/0.0
host: www.epita.fr port: 80 proxy_port: 3128
method: GET
rhttpr_raw2rqdata() permits the users to fill the field "data" in the
structure rq (SEE SECTION: STRUCTURE CONTENT). It also sets the
"data_len" field with the "data" length. This function copies the
exact data in the structure.
rhttpr_list2rqdata() permits the users to fill the field "data" in the
structure rq (SEE SECTION: STRUCTURE CONTENT). It also sets "data_len"
field with the "data" length. This function takes a list and
url_encode each part of the list to create the "data" string.
rhttpr_rq_set_proxy() fills the field "proxy" which is the name of
proxy server.
rhttpr_rq_set_proxy_port() fills the field "proxy_port" which is the
port number of proxy service.
rhttpr_rq_set_proxy_user() allows to set the proxy user name.
rhttpr_rq_set_proxy_passwd() allows to set the proxy passwd for the
user.
rhttpr_rq_set_user_agent() allows to set the "user agent" field, by
default user agent is "flav/0.0".
rhttpr_rq_set_host() allows to set the "host" field, by default host
is "www.epita.fr".
rhttpr_rq_set_port() allows to set the "port" field, by default port
is 80.
rhttpr_rq_set_referer() allows to set the "referer" field, by default
referer is null. If referer is not set, it is not include in the
- 3 - Formatted: October 25, 2025
LIBRHTTPR(3) librhttpr 0.0 LIBRHTTPR(3)
01 17 2000
request.
rhttpr_rq_set_cookie() allows to set the "cookie" field, by default
cookie is null. If cookie is not set, it is not include in the
request.
rhttpr_rq_set_method() allows to set the method for the request, by
default the method is GET. The method is coded by an integer:
Code method 0 GET 1 POST 2 HEAD
Only those methods are implemented at the moment.
rhttpr_rq_set_action() allows to set the "action" field, by default
action is null.
rhttpr_rq_set_contentype() allows to set the "contentype" field.
rhttpr_mk_rq() makes the connection to the host or to the proxy server
and makes the request, returns a allocated pointer in a rs filled
structure (SEE SECTION: STRUCTURE CONTENT). mk_rq returns a null
pointer if connection failed.
REPONSE DEALING ROUTINES
The rhttpr_rs_get_XXX() functions permit the user to get from the rs
structure differents parts of the reponse.
rhttpr_rs_get_version() allows to get the version.
rhttpr_rs_get_val_ret() allows to get the return code value.
rhttpr_rs_get_msg_ret() allows to get the return message.
rhttpr_rs_get_con_len() allows to get the content lenght of the data
reponse.
rhttpr_rs_get_con_typ() allows to get the content type of the data
reponse.
rhttpr_rs_get_server() allows to get the server.
rhttpr_rs_get_date() allows to get the date of the reponse.
rhttpr_rs_get_last_modif allows to get the last modification date of
the reponse.
- 4 - Formatted: October 25, 2025
LIBRHTTPR(3) librhttpr 0.0 LIBRHTTPR(3)
01 17 2000
rhttpr_rs_get_data() allows to get the data of the reponse.
rhttpr_rs_get_next_field() gets the name and the value in a t_list
structure. It returns 0 if it is the end of the list else it returns 1
and fill the parameters "name" and "val".
DESTROY STRUCTURE ROUTINES
rhttpr_free_rq() frees every field in the rq structure and frees the
pointer to the rq structure.
rhttpr_free_rs() frees every field in the rs structure and frees the
pointer to the rs structure.
RFC
RFC-1945, RFC-2068
AUTHOR
flav <flav@epita.fr> See the online web reference manual for
additional contributers. The current version is always available:
http://www.epita.fr/~flav/rhttpr/ or
http://www.epita.fr/~lse/misc/librhttpr
Please send bug reports to flav@epita.fr.
- 5 - Formatted: October 25, 2025