Http.h

Go to the documentation of this file.
00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_HTTP_H
00026 #define SFML_HTTP_H
00027 
00029 // Headers
00031 #include <SFML/Config.h>
00032 
00033 
00037 enum sfHttpMethod
00038 {
00039     sfHttpGet,  
00040     sfHttpPost, 
00041     sfHttpHead  
00042 };
00043 
00044 
00049 enum sfHttpStatus
00050 {
00051     // 2xx: success
00052     sfHttpOk        = 200, 
00053     sfHttpCreated   = 201, 
00054     sfHttpAccepted  = 202, 
00055     sfHttpNoContent = 204, 
00056 
00057     // 3xx: redirection
00058     sfHttpMultipleChoices  = 300, 
00059     sfHttpMovedPermanently = 301, 
00060     sfHttpMovedTemporarily = 302, 
00061     sfHttpNotModified      = 304, 
00062 
00063     // 4xx: client error
00064     sfHttpBadRequest   = 400, 
00065     sfHttpUnauthorized = 401, 
00066     sfHttpForbidden    = 403, 
00067     sfHttpNotFound     = 404, 
00068 
00069     // 5xx: server error
00070     sfHttpInternalServerError = 500, 
00071     sfHttpNotImplemented      = 501, 
00072     sfHttpBadGateway          = 502, 
00073     sfHttpServiceNotAvailable = 503, 
00074 
00075     // 10xx: SFML custom codes
00076     sfHttpInvalidResponse  = 1000, 
00077     sfHttpConnectionFailed = 1001  
00078 };
00079 
00080 
00086 typedef struct sfHttpRequest sfHttpRequest;
00087 
00088 
00095 CSFML_API sfHttpRequest* sfHttpRequest_Create();
00096 
00103 CSFML_API void sfHttpRequest_Destroy(sfHttpRequest* HttpRequest);
00104 
00113 CSFML_API void sfHttpRequest_SetField(sfHttpRequest* HttpRequest, const char* Field, const char* Value);
00114 
00123 CSFML_API void sfHttpRequest_SetMethod(sfHttpRequest* HttpRequest, sfHttpMethod Method);
00124 
00133 CSFML_API void sfHttpRequest_SetURI(sfHttpRequest* HttpRequest, const char* URI);
00134 
00144 CSFML_API void sfHttpRequest_SetHttpVersion(sfHttpRequest* HttpRequest, unsigned int Major, unsigned int Minor);
00145 
00155 CSFML_API void sfHttpRequest_SetBody(sfHttpRequest* HttpRequest, const char* Body);
00156 
00157 
00163 typedef struct sfHttpResponse sfHttpResponse;
00164 
00165 
00172 CSFML_API void sfHttpResponse_Destroy(sfHttpResponse* HttpResponse);
00173 
00183 CSFML_API const char* sfHttpResponse_GetField(sfHttpResponse* HttpResponse, const char* Field);
00184 
00193 CSFML_API sfHttpStatus sfHttpResponse_GetStatus(sfHttpResponse* HttpResponse);
00194 
00203 CSFML_API unsigned int sfHttpResponse_GetMajorVersion(sfHttpResponse* HttpResponse);
00204 
00213 CSFML_API unsigned int sfHttpResponse_GetMinorVersion(sfHttpResponse* HttpResponse);
00214 
00227 CSFML_API const char* sfHttpResponse_GetBody(sfHttpResponse* HttpResponse);
00228 
00229 
00235 typedef struct sfHttp sfHttp;
00236 
00237 
00244 CSFML_API sfHttp* sfHttp_Create();
00245 
00252 CSFML_API void sfHttp_Destroy(sfHttp* Http);
00253 
00262 CSFML_API void sfHttp_SetHost(sfHttp* Http, const char* Host, unsigned short Port);
00263 
00278 CSFML_API sfHttpResponse* sfHttp_SendRequest(sfHttp* Http, sfHttpRequest* Request);
00279 
00280 
00281 #endif // SFML_HTTP_H