libxrdeveloper's documentation
xr-http.h
Go to the documentation of this file.
00001 /* 
00002  * Copyright 2006-2008 Ondrej Jirman <ondrej.jirman@zonio.net>
00003  * 
00004  * This file is part of libxr.
00005  *
00006  * Libxr is free software: you can redistribute it and/or modify it under the
00007  * terms of the GNU Lesser General Public License as published by the Free
00008  * Software Foundation, either version 2 of the License, or (at your option) any
00009  * later version.
00010  *
00011  * Libxr is distributed in the hope that it will be useful, but WITHOUT ANY
00012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00013  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00014  * details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with libxr.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #ifndef __XR_HTTP_H__
00021 #define __XR_HTTP_H__
00022 
00023 #include <glib.h>
00024 #include <openssl/bio.h>
00025 
00046 typedef struct _xr_http xr_http;
00047 
00050 typedef enum {
00051   XR_HTTP_NONE,
00052   XR_HTTP_REQUEST,
00053   XR_HTTP_RESPONSE
00054 } xr_http_message_type;
00055 
00056 #define XR_HTTP_ERROR xr_http_error_quark()
00057 
00058 typedef enum
00059 {
00060   XR_HTTP_ERROR_FAILED = 1
00061 } XRHttpError;
00062 
00063 G_BEGIN_DECLS
00064 
00067 void xr_http_init();
00068 
00075 xr_http* xr_http_new(BIO* bio);
00076 
00081 void xr_http_free(xr_http* http);
00082 
00083 /* receive API */
00084 
00092 gboolean xr_http_read_header(xr_http* http, GError** err);
00093 
00101 const char* xr_http_get_header(xr_http* http, const char* name);
00102 
00109 void xr_http_set_basic_auth(xr_http* http, const char* username, const char* password);
00110 
00121 gboolean xr_http_get_basic_auth(xr_http* http, char** username, char** password);
00122 
00129 const char* xr_http_get_method(xr_http* http);
00130 
00137 int xr_http_get_code(xr_http* http);
00138 
00145 const char* xr_http_get_resource(xr_http* http);
00146 
00153 int xr_http_get_version(xr_http* http);
00154 
00162 xr_http_message_type xr_http_get_message_type(xr_http* http);
00163 
00172 gssize xr_http_get_message_length(xr_http* http);
00173 
00183 gssize xr_http_read(xr_http* http, char* buffer, gsize length, GError** err);
00184 
00192 GString* xr_http_read_all(xr_http* http, GError** err);
00193 
00194 /* transmit API */
00195 
00202 void xr_http_set_header(xr_http* http, const char* name, const char* value);
00203 
00209 void xr_http_set_message_type(xr_http* http, xr_http_message_type type);
00210 
00216 void xr_http_set_message_length(xr_http* http, gsize length);
00217 
00225 void xr_http_setup_request(xr_http* http, const char* method, const char* resource, const char* host);
00226 
00232 void xr_http_setup_response(xr_http* http, int code);
00233 
00244 gboolean xr_http_write_header(xr_http* http, GError** err);
00245 
00260 gboolean xr_http_write(xr_http* http, const char* buffer, gsize length, GError** err);
00261 
00272 gboolean xr_http_write_complete(xr_http* http, GError** err);
00273 
00283 gboolean xr_http_write_all(xr_http* http, const char* buffer, gssize length, GError** err);
00284 
00291 gboolean xr_http_is_ready(xr_http* http);
00292 
00300 gboolean xr_http_has_pending_request(xr_http* http, time_t timeout);
00301 
00302 GQuark xr_http_error_quark();
00303 
00304 G_END_DECLS
00305 
00306 #endif
Documentation for libxr, Tue Jun 7 2011 18:50:29.