1#ifndef UPNPLIB_HTTPREADWRITE_HPP
2#define UPNPLIB_HTTPREADWRITE_HPP
37 virtual ~Ihttpreadwrite() {}
41 const time_t* clock,
struct tm* result) = 0;
47 const char* urlstr,
size_t urlstrlen,
uri_type* fixed_url) = 0;
54 int* timeout_secs,
int* http_error_code) = 0;
59 uri_type* destination,
const char* request,
size_t request_length,
63 const char* url_str,
int timeout_secs,
char** document,
64 size_t* doc_length,
char* content_type) = 0;
68 int contentLength,
const char* contentType,
const UpnpString* headers) = 0;
71 void* Handle,
size_t* length,
size_t* total) = 0;
77 const char* url_str,
void** Handle,
int timeout) = 0;
81 const char* contentType,
int contentLength,
int timeout) = 0;
84 void* Handle,
char* buf,
size_t* size,
int timeout) = 0;
87 void* Handle,
int timeout) = 0;
90 void* Handle,
UpnpString* headers,
char** contentType,
int* contentLength,
91 int* httpStatus,
int timeout) = 0;
94 void* Handle,
char* buf,
size_t* size,
int timeout) = 0;
100 SOCKINFO* info,
int http_status_code,
int request_major_version,
101 int request_minor_version) = 0;
107 int request_major_vers,
int request_minor_vers,
int* response_major_vers,
108 int* response_minor_vers) = 0;
115 const char* url_str,
void** Handle,
char** contentType,
int* contentLength,
116 int* httpStatus,
int lowRange,
int highRange,
int timeout) = 0;
119 char* info,
size_t infoSize) = 0;
125class Chttpreadwrite_old : Ihttpreadwrite {
127 virtual ~Chttpreadwrite_old()
override {}
129 struct tm*
http_gmtime_r(
const time_t* clock,
struct tm* result)
override {
130 return ::http_gmtime_r(clock, result); }
132 return ::http_FixUrl(url, fixed_url); }
134 return ::http_FixStrUrl(urlstr, urlstrlen, fixed_url); }
136 return ::http_Connect(destination_url, url); }
138 return ::http_RecvMessage(info, parser, request_method, timeout_secs, http_error_code); }
143 return ::http_RequestAndResponse(destination, request, request_length, req_method, timeout_secs, response); }
144 int http_Download(
const char* url_str,
int timeout_secs,
char** document,
size_t* doc_length,
char* content_type)
override {
145 return ::http_Download(url_str, timeout_secs, document, doc_length, content_type); }
147 return ::MakeGenericMessage(method, url_str, request, url, contentLength, contentType, headers); }
149 return ::http_HttpGetProgress(Handle, length, total); }
151 return ::http_CancelHttpGet(Handle); }
153 return ::http_OpenHttpConnection(url_str, Handle, timeout); }
155 return ::http_MakeHttpRequest(method, url_str, Handle, headers, contentType, contentLength, timeout); }
157 return ::http_WriteHttpRequest(Handle, buf, size, timeout); }
159 return ::http_EndHttpRequest(Handle, timeout); }
161 return ::http_GetHttpResponse(Handle, headers, contentType, contentLength, httpStatus, timeout); }
163 return ::http_ReadHttpResponse(Handle, buf, size, timeout); }
165 return ::http_CloseHttpConnection(Handle); }
167 return ::http_SendStatusResponse(info, http_status_code, request_major_version, request_minor_version); }
171 void http_CalcResponseVersion(
int request_major_vers,
int request_minor_vers,
int* response_major_vers,
int* response_minor_vers)
override {
172 return ::http_CalcResponseVersion(request_major_vers, request_minor_vers, response_major_vers, response_minor_vers); }
174 return ::MakeGetMessageEx(url_str, request, url, pRangeSpecifier); }
175 int http_OpenHttpGetEx(
const char* url_str,
void** Handle,
char** contentType,
int* contentLength,
int* httpStatus,
int lowRange,
int highRange,
int timeout)
override {
176 return ::http_OpenHttpGetEx(url_str, Handle, contentType, contentLength, httpStatus, lowRange, highRange, timeout); }
177 void get_sdk_info(
char* info,
size_t infoSize)
override {
178 return ::get_sdk_info(info, infoSize); }
183class Chttpreadwrite: Chttpreadwrite_old {
185 virtual ~Chttpreadwrite()
override {}
243 CUri(std::string a_url_str);
int http_ReadHttpResponse(void *Handle, char *buf, size_t *size, int timeout)
Reads the content of a response using a connection previously created by UpnpOpenHttpConnection().
int http_OpenHttpConnection(const char *url_str, void **Handle, int timeout)
Opens a connection to the server.
int http_RequestAndResponse(uri_type *destination, const char *request, size_t request_length, http_method_t req_method, int timeout_secs, http_parser_t *response)
Initiates socket, connects to the remote host, sends a request and waits for the response from the re...
int http_CloseHttpConnection(void *Handle)
Closes the connection created with UpnpOpenHttpConnection() and frees any memory associated with the ...
int http_FixStrUrl(const char *urlstr, size_t urlstrlen, uri_type *fixed_url)
Parses URL and then validates URL.
SOCKET http_Connect(uri_type *destination_url, uri_type *url)
Gets destination address from URL and then connects to the remote end.
void get_sdk_info(char *info, size_t infoSize)
Returns the server information for the operating system.
int http_Download(const char *url_str, int timeout_secs, char **document, size_t *doc_length, char *content_type)
Download the document message and extract the document from the message.
int http_FixUrl(uri_type *url, uri_type *fixed_url)
Validates URL.
int http_CancelHttpGet(void *Handle)
Set the cancel flag of the HttpGet handle.
int http_WriteHttpRequest(void *Handle, char *buf, size_t *size, int timeout)
Writes the content of a HTTP request initiated by a UpnpMakeHttpRequest() call. The end of the conten...
void http_CalcResponseVersion(int request_major_vers, int request_minor_vers, int *response_major_vers, int *response_minor_vers)
Calculate HTTP response versions based on the request versions.
tm * http_gmtime_r(const time_t *clock, tm *result)
Portable gmtime_r for Microsoft Windows.
int http_EndHttpRequest(void *Handle, int timeout)
Indicates the end of a HTTP request previously made by UpnpMakeHttpRequest().
int http_SendStatusResponse(SOCKINFO *info, int http_status_code, int request_major_version, int request_minor_version)
Generate a response message for the status query and send the status response.
int http_OpenHttpGetEx(const char *url_str, void **Handle, char **contentType, int *contentLength, int *httpStatus, int lowRange, int highRange, int timeout)
Makes the HTTP GET message, connects to the peer, sends the HTTP GET request, gets the response and p...
int http_GetHttpResponse(void *Handle, UpnpString *headers, char **contentType, int *contentLength, int *httpStatus, int timeout)
Gets the response from the server using a connection previously created by UpnpOpenHttpConnection().
int http_MakeHttpRequest(Upnp_HttpMethod method, const char *url_str, void *Handle, UpnpString *headers, const char *contentType, int contentLength, int timeout)
Makes a HTTP request using a connection previously created by UpnpOpenHttpConnection().
int http_RecvMessage(SOCKINFO *info, http_parser_t *parser, http_method_t request_method, int *timeout_secs, int *http_error_code)
Get the data on the socket and take actions based on the read data to modify the parser objects buffe...
int http_HttpGetProgress(void *Handle, size_t *length, size_t *total)
Extracts information from the Handle to the HTTP get object.
http_method_t
Method in a HTTP request.
Structure of an HTTP parser object.
Represents a URI used in parse_uri and elsewhere.
Stores a URL and provides its host with port part.
const std::string url_str
URL.
std::string hostport
Host with port part from the URL.
Internal implementation of the class UpnpString.
Upnp_HttpMethod
Different HTTP methods.
Maintains a block of dynamically allocated memory.
Reengineered Object Oriented UPnP+ program code.
int MakeGetMessageEx(const char *url_str, membuffer *request, uri_type *url, SendInstruction *pRangeSpecifier)
Make extended GetMessage.
int MakeGenericMessage(http_method_t method, const char *url_str, membuffer *request, uri_type *url, int contentLength, const char *contentType, const UpnpString *headers)
Make a generic message, what ever this mean.
Additional socket information for connections and ssl.
#define UPnPsdk_VIS
Prefix to export symbol for external use.