Some rework of http_SendMessage(), no change in functionality. Mostly white spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@246 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
f42bbb6dc2
commit
851cfbc4db
@ -70,8 +70,10 @@
|
|||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "webserver.h"
|
#include "webserver.h"
|
||||||
|
|
||||||
#define DOSOCKET_READ 1
|
|
||||||
#define DOSOCKET_WRITE 0
|
const int CHUNK_HEADER_SIZE = 10;
|
||||||
|
const int CHUNK_TAIL_SIZE = 10;
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_FixUrl
|
* Function: http_FixUrl
|
||||||
@ -80,7 +82,8 @@
|
|||||||
* IN uri_type* url; URL to be validated and fixed
|
* IN uri_type* url; URL to be validated and fixed
|
||||||
* OUT uri_type* fixed_url; URL after being fixed.
|
* OUT uri_type* fixed_url; URL after being fixed.
|
||||||
*
|
*
|
||||||
* Description: Validates URL
|
* Description:
|
||||||
|
* Validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@ -110,6 +113,7 @@ http_FixUrl( IN uri_type * url,
|
|||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_FixStrUrl
|
* Function: http_FixStrUrl
|
||||||
*
|
*
|
||||||
@ -118,7 +122,8 @@ http_FixUrl( IN uri_type * url,
|
|||||||
* IN int urlstrlen ; Length of the character string
|
* IN int urlstrlen ; Length of the character string
|
||||||
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Parses URL and then validates URL
|
* Description:
|
||||||
|
* Parses URL and then validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@ -138,6 +143,7 @@ http_FixStrUrl( IN char *urlstr,
|
|||||||
return http_FixUrl( &url, fixed_url );
|
return http_FixUrl( &url, fixed_url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_Connect
|
* Function: http_Connect
|
||||||
*
|
*
|
||||||
@ -145,8 +151,8 @@ http_FixStrUrl( IN char *urlstr,
|
|||||||
* IN uri_type* destination_url; URL containing destination information
|
* IN uri_type* destination_url; URL containing destination information
|
||||||
* OUT uri_type *url; Fixed and corrected URL
|
* OUT uri_type *url; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Gets destination address from URL and then connects to the
|
* Description:
|
||||||
* remote end
|
* Gets destination address from URL and then connects to the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* socket descriptor on sucess
|
* socket descriptor on sucess
|
||||||
@ -180,19 +186,21 @@ http_Connect( IN uri_type * destination_url,
|
|||||||
return connfd;
|
return connfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RecvMessage
|
* Function: http_RecvMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info; Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* OUT http_parser_t* parser, HTTP parser object
|
* OUT http_parser_t* parser; HTTP parser object
|
||||||
* IN http_method_t request_method; HTTP request method
|
* IN http_method_t request_method; HTTP request method
|
||||||
* IN OUT int* timeout_secs; time out
|
* IN OUT int* timeout_secs; time out
|
||||||
* OUT int* http_error_code; HTTP error code returned
|
* OUT int* http_error_code; HTTP error code returned
|
||||||
*
|
*
|
||||||
* Description: Get the data on the socket and take actions based on the
|
* Description:
|
||||||
* read data to modify the parser objects buffer. If an error is reported
|
* Get the data on the socket and take actions based on the read data
|
||||||
* while parsing the data, the error code is passed in the http_errr_code
|
* to modify the parser objects buffer. If an error is reported while
|
||||||
|
* parsing the data, the error code is passed in the http_errr_code
|
||||||
* parameter
|
* parameter
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@ -266,6 +274,7 @@ http_RecvMessage( IN SOCKINFO * info,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_SendMessage
|
* Function: http_SendMessage
|
||||||
*
|
*
|
||||||
@ -274,7 +283,8 @@ http_RecvMessage( IN SOCKINFO * info,
|
|||||||
* IN OUT int * TimeOut ; time out value
|
* IN OUT int * TimeOut ; time out value
|
||||||
* IN const char* fmt, ... Pattern format to take actions upon
|
* IN const char* fmt, ... Pattern format to take actions upon
|
||||||
*
|
*
|
||||||
* Description: Sends a message to the destination based on the
|
* Description:
|
||||||
|
* Sends a message to the destination based on the
|
||||||
* IN const char* fmt parameter
|
* IN const char* fmt parameter
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 'f': arg = const char * file name
|
* 'f': arg = const char * file name
|
||||||
@ -297,22 +307,19 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
IN const char *fmt,
|
IN const char *fmt,
|
||||||
... )
|
... )
|
||||||
{
|
{
|
||||||
#define CHUNK_HEADER_SIZE 10
|
|
||||||
#define CHUNK_TAIL_SIZE 10
|
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
size_t buf_length;
|
size_t buf_length;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
FILE *Fp;
|
FILE *Fp;
|
||||||
int num_read,
|
int num_read;
|
||||||
num_written;
|
int num_written;
|
||||||
off_t amount_to_be_read = 0;
|
off_t amount_to_be_read = 0;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
char *file_buf = NULL,
|
char *file_buf = NULL;
|
||||||
*ChunkBuf = NULL;
|
char *ChunkBuf = NULL;
|
||||||
struct SendInstruction *Instr = NULL;
|
struct SendInstruction *Instr = NULL;
|
||||||
char Chunk_Header[10];
|
char Chunk_Header[CHUNK_HEADER_SIZE];
|
||||||
int RetVal = 0;
|
int RetVal = 0;
|
||||||
|
|
||||||
// 10 byte allocated for chunk header.
|
// 10 byte allocated for chunk header.
|
||||||
@ -322,44 +329,40 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
|
|
||||||
while( ( c = *fmt++ ) != 0 ) {
|
while( ( c = *fmt++ ) != 0 ) {
|
||||||
if( c == 'I' ) {
|
if( c == 'I' ) {
|
||||||
Instr = ( struct SendInstruction * )
|
Instr = va_arg(argp, struct SendInstruction *);
|
||||||
va_arg( argp, struct SendInstruction * );
|
|
||||||
|
|
||||||
assert( Instr );
|
assert( Instr );
|
||||||
|
|
||||||
if( Instr->ReadSendSize >= 0 )
|
if( Instr->ReadSendSize >= 0 ) {
|
||||||
amount_to_be_read = Instr->ReadSendSize;
|
amount_to_be_read = Instr->ReadSendSize;
|
||||||
else
|
} else {
|
||||||
amount_to_be_read = Data_Buf_Size;
|
amount_to_be_read = Data_Buf_Size;
|
||||||
|
|
||||||
if( amount_to_be_read < WEB_SERVER_BUF_SIZE )
|
|
||||||
Data_Buf_Size = amount_to_be_read;
|
|
||||||
|
|
||||||
ChunkBuf = ( char * )malloc( Data_Buf_Size +
|
|
||||||
CHUNK_HEADER_SIZE +
|
|
||||||
CHUNK_TAIL_SIZE );
|
|
||||||
if( !ChunkBuf )
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
|
||||||
|
|
||||||
file_buf = ChunkBuf + 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( c == 'f' ) { // file name
|
if( amount_to_be_read < WEB_SERVER_BUF_SIZE ) {
|
||||||
|
Data_Buf_Size = amount_to_be_read;
|
||||||
|
}
|
||||||
|
|
||||||
filename = ( char * )va_arg( argp, char * );
|
ChunkBuf = (char *)malloc(
|
||||||
|
Data_Buf_Size + CHUNK_HEADER_SIZE + CHUNK_TAIL_SIZE);
|
||||||
|
if( !ChunkBuf ) {
|
||||||
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if( Instr && Instr->IsVirtualFile )
|
file_buf = ChunkBuf + CHUNK_HEADER_SIZE;
|
||||||
|
} else if( c == 'f' ) {
|
||||||
|
// file name
|
||||||
|
filename = va_arg(argp, char *);
|
||||||
|
if( Instr && Instr->IsVirtualFile ) {
|
||||||
Fp = (virtualDirCallback.open)( filename, UPNP_READ );
|
Fp = (virtualDirCallback.open)( filename, UPNP_READ );
|
||||||
else
|
} else {
|
||||||
Fp = fopen( filename, "rb" );
|
Fp = fopen( filename, "rb" );
|
||||||
|
}
|
||||||
if( Fp == NULL ) {
|
if( Fp == NULL ) {
|
||||||
free( ChunkBuf );
|
free( ChunkBuf );
|
||||||
return UPNP_E_FILE_READ_ERROR;
|
return UPNP_E_FILE_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert( Fp );
|
|
||||||
|
|
||||||
if( Instr && Instr->IsRangeActive && Instr->IsVirtualFile ) {
|
if( Instr && Instr->IsRangeActive && Instr->IsVirtualFile ) {
|
||||||
if( virtualDirCallback.seek( Fp, Instr->RangeOffset,
|
if( virtualDirCallback.seek( Fp, Instr->RangeOffset,
|
||||||
SEEK_CUR ) != 0 ) {
|
SEEK_CUR ) != 0 ) {
|
||||||
@ -375,26 +378,14 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
|
|
||||||
while( amount_to_be_read ) {
|
while( amount_to_be_read ) {
|
||||||
if( Instr ) {
|
if( Instr ) {
|
||||||
if( amount_to_be_read >= Data_Buf_Size ) {
|
int n = (amount_to_be_read >= Data_Buf_Size) ?
|
||||||
if( Instr->IsVirtualFile )
|
Data_Buf_Size : amount_to_be_read;
|
||||||
num_read = virtualDirCallback.read( Fp,
|
if( Instr->IsVirtualFile ) {
|
||||||
file_buf,
|
num_read = virtualDirCallback.read( Fp, file_buf, n );
|
||||||
Data_Buf_Size );
|
|
||||||
else
|
|
||||||
num_read = fread( file_buf, 1, Data_Buf_Size,
|
|
||||||
Fp );
|
|
||||||
} else {
|
} else {
|
||||||
if( Instr->IsVirtualFile )
|
num_read = fread( file_buf, 1, n, Fp );
|
||||||
num_read = virtualDirCallback.read( Fp,
|
|
||||||
file_buf,
|
|
||||||
amount_to_be_read );
|
|
||||||
else
|
|
||||||
num_read = fread( file_buf, 1,
|
|
||||||
amount_to_be_read, Fp );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
amount_to_be_read = amount_to_be_read - num_read;
|
amount_to_be_read = amount_to_be_read - num_read;
|
||||||
|
|
||||||
if( Instr->ReadSendSize < 0 ) {
|
if( Instr->ReadSendSize < 0 ) {
|
||||||
// read until close
|
// read until close
|
||||||
amount_to_be_read = Data_Buf_Size;
|
amount_to_be_read = Data_Buf_Size;
|
||||||
@ -403,12 +394,11 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
num_read = fread( file_buf, 1, Data_Buf_Size, Fp );
|
num_read = fread( file_buf, 1, Data_Buf_Size, Fp );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( num_read == 0 ) // EOF so no more to send.
|
if( num_read == 0 ) {
|
||||||
{
|
// EOF so no more to send.
|
||||||
if( Instr && Instr->IsChunkActive ) {
|
if( Instr && Instr->IsChunkActive ) {
|
||||||
num_written = sock_write( info, "0\r\n\r\n",
|
char *str = "0\r\n\r\n";
|
||||||
strlen( "0\r\n\r\n" ),
|
num_written = sock_write(info, str, strlen(str), TimeOut);
|
||||||
TimeOut );
|
|
||||||
} else {
|
} else {
|
||||||
RetVal = UPNP_E_FILE_READ_ERROR;
|
RetVal = UPNP_E_FILE_READ_ERROR;
|
||||||
}
|
}
|
||||||
@ -432,47 +422,41 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
// on the top of the buffer.
|
// on the top of the buffer.
|
||||||
//file_buf[num_read+strlen(Chunk_Header)] = NULL;
|
//file_buf[num_read+strlen(Chunk_Header)] = NULL;
|
||||||
//printf("Sending %s\n",file_buf-strlen(Chunk_Header));
|
//printf("Sending %s\n",file_buf-strlen(Chunk_Header));
|
||||||
num_written = sock_write( info,
|
num_written = sock_write(
|
||||||
file_buf -
|
info, file_buf - strlen( Chunk_Header ),
|
||||||
strlen( Chunk_Header ),
|
num_read + strlen( Chunk_Header ) + 2, TimeOut );
|
||||||
num_read +
|
|
||||||
strlen( Chunk_Header ) + 2,
|
|
||||||
TimeOut );
|
|
||||||
|
|
||||||
if( num_written !=
|
if( num_written !=
|
||||||
num_read + ( int )strlen( Chunk_Header )
|
num_read + ( int )strlen( Chunk_Header ) + 2 ) {
|
||||||
+ 2 ) {
|
// Send error nothing we can do.
|
||||||
goto Cleanup_File; //Send error nothing we can do.
|
goto Cleanup_File;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// write data
|
// write data
|
||||||
num_written = sock_write( info, file_buf, num_read,
|
num_written = sock_write( info, file_buf, num_read, TimeOut );
|
||||||
TimeOut );
|
|
||||||
|
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
">>> (SENT) >>>\n%.*s\n------------\n",
|
">>> (SENT) >>>\n%.*s\n------------\n",
|
||||||
( int )num_written, file_buf );
|
( int )num_written, file_buf );
|
||||||
|
|
||||||
// Send error nothing we can do
|
// Send error nothing we can do
|
||||||
if( num_written != num_read ) {
|
if( num_written != num_read ) {
|
||||||
goto Cleanup_File;
|
goto Cleanup_File;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //While
|
} // while
|
||||||
Cleanup_File:
|
Cleanup_File:
|
||||||
va_end( argp );
|
va_end( argp );
|
||||||
if( Instr && Instr->IsVirtualFile )
|
if( Instr && Instr->IsVirtualFile ) {
|
||||||
virtualDirCallback.close( Fp );
|
virtualDirCallback.close( Fp );
|
||||||
else
|
} else {
|
||||||
fclose( Fp );
|
fclose( Fp );
|
||||||
|
}
|
||||||
free( ChunkBuf );
|
free( ChunkBuf );
|
||||||
return RetVal;
|
return RetVal;
|
||||||
|
|
||||||
} else if( c == 'b' ) { // memory buffer
|
} else if( c == 'b' ) {
|
||||||
|
// memory buffer
|
||||||
buf = ( char * )va_arg( argp, char * );
|
buf = va_arg(argp, char *);
|
||||||
|
buf_length = va_arg(argp, size_t);
|
||||||
buf_length = ( size_t ) va_arg( argp, size_t );
|
|
||||||
if( buf_length > 0 ) {
|
if( buf_length > 0 ) {
|
||||||
num_written = sock_write( info, buf, buf_length, TimeOut );
|
num_written = sock_write( info, buf, buf_length, TimeOut );
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
@ -480,11 +464,12 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
"%.*s\nbuf_length=%d, num_written=%d\n"
|
"%.*s\nbuf_length=%d, num_written=%d\n"
|
||||||
"------------\n",
|
"------------\n",
|
||||||
(int)buf_length, buf, (int)buf_length, num_written );
|
(int)buf_length, buf, (int)buf_length, num_written );
|
||||||
if( ( size_t ) num_written != buf_length )
|
if( (size_t)num_written != buf_length ) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
va_end( argp );
|
va_end( argp );
|
||||||
@ -492,6 +477,7 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RequestAndResponse
|
* Function: http_RequestAndResponse
|
||||||
*
|
*
|
||||||
@ -504,7 +490,8 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
* IN int timeout_secs; time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT http_parser_t* response; Parser object to receive the repsonse
|
* OUT http_parser_t* response; Parser object to receive the repsonse
|
||||||
*
|
*
|
||||||
* Description: Initiates socket, connects to the destination, sends a
|
* Description:
|
||||||
|
* Initiates socket, connects to the destination, sends a
|
||||||
* request and waits for the response from the remote end
|
* request and waits for the response from the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@ -564,25 +551,25 @@ http_RequestAndResponse( IN uri_type * destination,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_Download
|
* Function: http_Download
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* url_str: String as a URL
|
* IN const char* url_str; String as a URL
|
||||||
* IN int timeout_secs: time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT char** document: buffer to store the document extracted
|
* OUT char** document; buffer to store the document extracted
|
||||||
* from the donloaded message.
|
* from the donloaded message.
|
||||||
* OUT int* doc_length: length of the extracted document
|
* OUT int* doc_length; length of the extracted document
|
||||||
* OUT char* content_type: Type of content
|
* OUT char* content_type; Type of content
|
||||||
*
|
*
|
||||||
* Description : Download the document message and extract the document
|
* Description:
|
||||||
|
* Download the document message and extract the document
|
||||||
* from the message.
|
* from the message.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS;
|
* UPNP_E_SUCCESS
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_Download( IN const char *url_str,
|
http_Download( IN const char *url_str,
|
||||||
@ -684,8 +671,8 @@ http_Download( IN const char *url_str,
|
|||||||
if( ( *doc_length = ( int )response.msg.entity.length ) == 0 ) {
|
if( ( *doc_length = ( int )response.msg.entity.length ) == 0 ) {
|
||||||
// 0-length msg
|
// 0-length msg
|
||||||
*document = NULL;
|
*document = NULL;
|
||||||
} else if( response.msg.status_code == HTTP_OK ) //LEAK_FIX_MK
|
} else if( response.msg.status_code == HTTP_OK ) {
|
||||||
{
|
//LEAK_FIX_MK
|
||||||
// copy entity
|
// copy entity
|
||||||
entity_start = response.msg.entity.buf; // what we want
|
entity_start = response.msg.entity.buf; // what we want
|
||||||
msg_length = response.msg.msg.length; // save for posterity
|
msg_length = response.msg.msg.length; // save for posterity
|
||||||
@ -727,12 +714,13 @@ typedef struct HTTPPOSTHANDLE {
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* const char *url_str; String as a URL
|
* const char *url_str; String as a URL
|
||||||
* membuffer *request; Buffer containing the request
|
* membuffer *request; Buffer containing the request
|
||||||
* uri_type *url ; URI object containing the scheme, path
|
* uri_type *url; URI object containing the scheme,
|
||||||
* query token, etc.
|
* path query token, etc.
|
||||||
* int contentLength; length of content
|
* int contentLength; length of content
|
||||||
* const char *contentType; Type of content
|
* const char *contentType; Type of content
|
||||||
*
|
*
|
||||||
* Description: Makes the message for the HTTP POST message
|
* Description:
|
||||||
|
* Makes the message for the HTTP POST message
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@ -834,15 +822,14 @@ MakePostMessage( const char *url_str,
|
|||||||
* IN unsigned int *size: Size of the data to be sent.
|
* IN unsigned int *size: Size of the data to be sent.
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Formats data if format used is UPNP_USING_CHUNKED.
|
* Description:
|
||||||
|
* Formats data if format used is UPNP_USING_CHUNKED.
|
||||||
* Writes data on the socket connected to the peer.
|
* Writes data on the socket connected to the peer.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* -1 - On Socket Error.
|
* -1 - On Socket Error.
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_WriteHttpPost( IN void *Handle,
|
http_WriteHttpPost( IN void *Handle,
|
||||||
@ -864,17 +851,18 @@ http_WriteHttpPost( IN void *Handle,
|
|||||||
if( handle->contentLength == UPNP_USING_CHUNKED ) {
|
if( handle->contentLength == UPNP_USING_CHUNKED ) {
|
||||||
if( ( *size ) ) {
|
if( ( *size ) ) {
|
||||||
int tempSize = 0;
|
int tempSize = 0;
|
||||||
|
tempbuf = ( char * )malloc(
|
||||||
|
*size + CHUNK_HEADER_SIZE + CHUNK_TAIL_SIZE );
|
||||||
|
if ( tempbuf == NULL) {
|
||||||
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
tempbuf =
|
// begin chunk
|
||||||
( char * )malloc( ( *size ) + CHUNK_HEADER_SIZE +
|
sprintf( tempbuf, "%x\r\n", ( *size ) );
|
||||||
CHUNK_TAIL_SIZE );
|
|
||||||
|
|
||||||
if ( tempbuf == NULL) return UPNP_E_OUTOF_MEMORY;
|
|
||||||
|
|
||||||
sprintf( tempbuf, "%x\r\n", ( *size ) ); //begin chunk
|
|
||||||
tempSize = strlen( tempbuf );
|
tempSize = strlen( tempbuf );
|
||||||
memcpy( tempbuf + tempSize, buf, ( *size ) );
|
memcpy( tempbuf + tempSize, buf, ( *size ) );
|
||||||
memcpy( tempbuf + tempSize + ( *size ), "\r\n", 2 ); //end of chunk
|
memcpy( tempbuf + tempSize + ( *size ), "\r\n", 2 );
|
||||||
|
// end of chunk
|
||||||
tempbufSize = tempSize + ( *size ) + 2;
|
tempbufSize = tempSize + ( *size ) + 2;
|
||||||
freeTempbuf = 1;
|
freeTempbuf = 1;
|
||||||
}
|
}
|
||||||
@ -903,20 +891,19 @@ http_WriteHttpPost( IN void *Handle,
|
|||||||
* Function: http_CloseHttpPost
|
* Function: http_CloseHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the http post object
|
* IN void *Handle; Handle to the http post object
|
||||||
* IN OUT int *httpStatus : HTTP status returned on receiving a
|
* IN OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Sends remaining data if using UPNP_USING_CHUNKED
|
* Description:
|
||||||
|
* Sends remaining data if using UPNP_USING_CHUNKED
|
||||||
* format. Receives any more messages. Destroys socket and any socket
|
* format. Receives any more messages. Destroys socket and any socket
|
||||||
* associated memory. Frees handle associated with the HTTP POST msg.
|
* associated memory. Frees handle associated with the HTTP POST msg.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_CloseHttpPost( IN void *Handle,
|
http_CloseHttpPost( IN void *Handle,
|
||||||
@ -957,25 +944,24 @@ http_CloseHttpPost( IN void *Handle,
|
|||||||
* Function: http_OpenHttpPost
|
* Function: http_OpenHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN const char *contentType : Type of content
|
* IN const char *contentType; Type of content
|
||||||
* IN int contentLength : length of content
|
* IN int contentLength; length of content
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP POST message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP POST message, connects to the peer,
|
||||||
* sends the HTTP POST request. Adds the post handle to buffer of
|
* sends the HTTP POST request. Adds the post handle to buffer of
|
||||||
* such handles
|
* such handles
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return : int;
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramter ;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_SOCKET_CONNECT ;
|
* UPNP_E_SOCKET_CONNECT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpPost( IN const char *url_str,
|
http_OpenHttpPost( IN const char *url_str,
|
||||||
@ -1063,7 +1049,8 @@ typedef struct HTTPGETHANDLE {
|
|||||||
* uri_type *url ; URI object containing the scheme, path
|
* uri_type *url ; URI object containing the scheme, path
|
||||||
* query token, etc.
|
* query token, etc.
|
||||||
*
|
*
|
||||||
* Description: Makes the message for the HTTP GET method
|
* Description:
|
||||||
|
* Makes the message for the HTTP GET method
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@ -1153,16 +1140,15 @@ MakeGetMessage( const char *url_str,
|
|||||||
* IN OUT int *timeout_secs; time out value
|
* IN OUT int *timeout_secs; time out value
|
||||||
* IN OUT int *http_error_code; HTTP errror code returned
|
* IN OUT int *http_error_code; HTTP errror code returned
|
||||||
*
|
*
|
||||||
* Description : Parses already exiting data. If not complete reads more
|
* Description:
|
||||||
|
* Parses already exiting data. If not complete reads more
|
||||||
* data on the connected socket. The read data is then parsed. The
|
* data on the connected socket. The read data is then parsed. The
|
||||||
* same methid is carried out for headers.
|
* same methid is carried out for headers.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* PARSE_OK - On Success
|
* PARSE_OK - On Success
|
||||||
* PARSE_FAILURE - Failure to parse data correctly
|
* PARSE_FAILURE - Failure to parse data correctly
|
||||||
* UPNP_E_BAD_HTTPMSG - Socker read() returns an error
|
* UPNP_E_BAD_HTTPMSG - Socker read() returns an error
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
ReadResponseLineAndHeaders( IN SOCKINFO * info,
|
ReadResponseLineAndHeaders( IN SOCKINFO * info,
|
||||||
@ -1273,22 +1259,21 @@ ReadResponseLineAndHeaders( IN SOCKINFO * info,
|
|||||||
* Function: http_ReadHttpGet
|
* Function: http_ReadHttpGet
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* IN OUT char *buf : Buffer to get the read and parsed data
|
* IN OUT char *buf; Buffer to get the read and parsed data
|
||||||
* IN OUT unsigned int *size : Size of the buffer passed
|
* IN OUT unsigned int *size; Size of the buffer passed
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Parses already existing data, then gets new data.
|
* Description:
|
||||||
|
* Parses already existing data, then gets new data.
|
||||||
* Parses and extracts information from the new data.
|
* Parses and extracts information from the new data.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
* UPNP_E_BAD_HTTPMSG ;
|
* UPNP_E_BAD_HTTPMSG
|
||||||
* UPNP_E_CANCELED ;
|
* UPNP_E_CANCELED
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_ReadHttpGet( IN void *Handle,
|
http_ReadHttpGet( IN void *Handle,
|
||||||
@ -1398,18 +1383,16 @@ http_ReadHttpGet( IN void *Handle,
|
|||||||
* Function: http_HttpGetProgress
|
* Function: http_HttpGetProgress
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* OUT unsigned int *length : Buffer to get the read and parsed data
|
* OUT unsigned int *length; Buffer to get the read and parsed data
|
||||||
* OUT unsigned int *total : Size of tge buffer passed
|
* OUT unsigned int *total; Size of tge buffer passed
|
||||||
*
|
*
|
||||||
* Description : Extracts information from the Handle to the HTTP get
|
* Description:
|
||||||
* object.
|
* Extracts information from the Handle to the HTTP get object.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_HttpGetProgress( IN void *Handle,
|
int http_HttpGetProgress( IN void *Handle,
|
||||||
OUT unsigned int *length,
|
OUT unsigned int *length,
|
||||||
@ -1431,13 +1414,12 @@ int http_HttpGetProgress( IN void *Handle,
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle; Handle to HTTP get object
|
* IN void *Handle; Handle to HTTP get object
|
||||||
*
|
*
|
||||||
* Description : Set the cancel flag of the HttpGet handle
|
* Description:
|
||||||
|
* Set the cancel flag of the HttpGet handle
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_CancelHttpGet( IN void *Handle )
|
http_CancelHttpGet( IN void *Handle )
|
||||||
@ -1460,14 +1442,13 @@ http_CancelHttpGet( IN void *Handle )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle; Handle to HTTP get object
|
* IN void *Handle; Handle to HTTP get object
|
||||||
*
|
*
|
||||||
* Description : Clears the handle allocated for the HTTP GET operation
|
* Description:
|
||||||
|
* Clears the handle allocated for the HTTP GET operation
|
||||||
* Clears socket states and memory allocated for socket operations.
|
* Clears socket states and memory allocated for socket operations.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_CloseHttpGet( IN void *Handle )
|
http_CloseHttpGet( IN void *Handle )
|
||||||
@ -1498,19 +1479,17 @@ http_CloseHttpGet( IN void *Handle )
|
|||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpGet( IN const char *url_str,
|
http_OpenHttpGet( IN const char *url_str,
|
||||||
@ -1527,30 +1506,27 @@ http_OpenHttpGet( IN const char *url_str,
|
|||||||
* Function: http_OpenHttpGetProxy
|
* Function: http_OpenHttpGetProxy
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN const char *proxy_str : String as a URL
|
* IN const char *proxy_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* response.
|
* sends the HTTP GET request, gets the response and parses the response.
|
||||||
* If a proxy URL is defined then the connection is made there.
|
* If a proxy URL is defined then the connection is made there.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpGetProxy( IN const char *url_str,
|
http_OpenHttpGetProxy( IN const char *url_str,
|
||||||
@ -1685,22 +1661,21 @@ http_OpenHttpGetProxy( IN const char *url_str,
|
|||||||
* Function: http_SendStatusResponse
|
* Function: http_SendStatusResponse
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info : Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* IN int http_status_code : error code returned while making
|
* IN int http_status_code; error code returned while making
|
||||||
* or sending the response message
|
* or sending the response message
|
||||||
* IN int request_major_version : request major version
|
* IN int request_major_version; request major version
|
||||||
* IN int request_minor_version : request minor version
|
* IN int request_minor_version; request minor version
|
||||||
*
|
*
|
||||||
* Description : Generate a response message for the status query and
|
* Description:
|
||||||
* send the status response.
|
* Generate a response message for the status query and send the
|
||||||
|
* status response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 -- success
|
* 0 -- success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_WRITE
|
* UPNP_E_SOCKET_WRITE
|
||||||
* UPNP_E_TIMEDOUT
|
* UPNP_E_TIMEDOUT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_SendStatusResponse( IN SOCKINFO * info,
|
http_SendStatusResponse( IN SOCKINFO * info,
|
||||||
@ -1736,23 +1711,26 @@ http_SendStatusResponse( IN SOCKINFO * info,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_MakeMessage
|
* Function: http_MakeMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* INOUT membuffer* buf : buffer with the contents of the
|
* INOUT membuffer* buf; buffer with the contents of the
|
||||||
* message
|
* message
|
||||||
* IN int http_major_version : HTTP major version
|
* IN int http_major_version; HTTP major version
|
||||||
* IN int http_minor_version : HTTP minor version
|
* IN int http_minor_version; HTTP minor version
|
||||||
* IN const char* fmt : Pattern format
|
* IN const char* fmt; Pattern format
|
||||||
* ... :
|
* ...;
|
||||||
*
|
*
|
||||||
* Description : Generate an HTTP message based on the format that is
|
* Description:
|
||||||
* specified in the input parameters.
|
* Generate an HTTP message based on the format that is specified
|
||||||
|
* in the input parameters.
|
||||||
*
|
*
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 'B': arg = int status_code
|
* 'B': arg = int status_code
|
||||||
* appends content-length, content-type and HTML body for given code
|
* appends content-length, content-type and HTML body
|
||||||
|
* for given code
|
||||||
* 'b': arg1 = const char* buf;
|
* 'b': arg1 = const char* buf;
|
||||||
* arg2 = size_t buf_length memory ptr
|
* arg2 = size_t buf_length memory ptr
|
||||||
* 'C': (no args) appends a HTTP CONNECTION: close header
|
* 'C': (no args) appends a HTTP CONNECTION: close header
|
||||||
@ -1778,12 +1756,10 @@ http_SendStatusResponse( IN SOCKINFO * info,
|
|||||||
* 'U': (no args) appends HTTP USER-AGENT: header
|
* 'U': (no args) appends HTTP USER-AGENT: header
|
||||||
* 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent
|
* 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 - On Success
|
* 0 - On Success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_MakeMessage( INOUT membuffer * buf,
|
http_MakeMessage( INOUT membuffer * buf,
|
||||||
@ -2038,21 +2014,20 @@ error_handler:
|
|||||||
return error_code;
|
return error_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CalcResponseVersion
|
* Function: http_CalcResponseVersion
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN int request_major_vers : Request major version
|
* IN int request_major_vers; Request major version
|
||||||
* IN int request_minor_vers : Request minor version
|
* IN int request_minor_vers; Request minor version
|
||||||
* OUT int* response_major_vers : Response mojor version
|
* OUT int* response_major_vers; Response mojor version
|
||||||
* OUT int* response_minor_vers : Response minor version
|
* OUT int* response_minor_vers; Response minor version
|
||||||
*
|
*
|
||||||
* Description : Calculate HTTP response versions based on the request
|
* Description:
|
||||||
* versions.
|
* Calculate HTTP response versions based on the request versions.
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void
|
void
|
||||||
http_CalcResponseVersion( IN int request_major_vers,
|
http_CalcResponseVersion( IN int request_major_vers,
|
||||||
@ -2080,7 +2055,8 @@ http_CalcResponseVersion( IN int request_major_vers,
|
|||||||
* uri_type *url; URI object containing the scheme, path
|
* uri_type *url; URI object containing the scheme, path
|
||||||
* query token, etc.
|
* query token, etc.
|
||||||
*
|
*
|
||||||
* Description: Makes the message for the HTTP GET method
|
* Description:
|
||||||
|
* Makes the message for the HTTP GET method
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@ -2167,28 +2143,26 @@ MakeGetMessageEx( const char *url_str,
|
|||||||
* Function: http_OpenHttpGetEx
|
* Function: http_OpenHttpGetEx
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
int
|
||||||
http_OpenHttpGetEx( IN const char *url_str,
|
http_OpenHttpGetEx( IN const char *url_str,
|
||||||
@ -2335,19 +2309,18 @@ http_OpenHttpGetEx( IN const char *url_str,
|
|||||||
return errCode;
|
return errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: get_sdk_info
|
* Function: get_sdk_info
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* OUT char *info : buffer to store the operating system
|
* OUT char *info; buffer to store the operating system information
|
||||||
* information
|
|
||||||
*
|
*
|
||||||
* Description : Returns the server information for the operating
|
* Description:
|
||||||
* system
|
* Returns the server information for the operating system
|
||||||
*
|
*
|
||||||
* Return : UPNP_INLINE void
|
* Return:
|
||||||
*
|
* UPNP_INLINE void
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
// 'info' should have a size of at least 100 bytes
|
// 'info' should have a size of at least 100 bytes
|
||||||
void
|
void
|
||||||
@ -2356,11 +2329,18 @@ get_sdk_info( OUT char *info )
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
OSVERSIONINFO versioninfo;
|
OSVERSIONINFO versioninfo;
|
||||||
versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
if (GetVersionEx(&versioninfo)!=0)
|
|
||||||
sprintf( info, "%d.%d.%d %d/%s, UPnP/1.0, Portable SDK for UPnP devices/"PACKAGE_VERSION"\r\n",
|
if (GetVersionEx(&versioninfo)!=0) {
|
||||||
versioninfo.dwMajorVersion, versioninfo.dwMinorVersion, versioninfo.dwBuildNumber, versioninfo.dwPlatformId, versioninfo.szCSDVersion );
|
sprintf( info,
|
||||||
else
|
"%d.%d.%d %d/%s, UPnP/1.0, Portable SDK for UPnP devices/"PACKAGE_VERSION"\r\n",
|
||||||
|
versioninfo.dwMajorVersion,
|
||||||
|
versioninfo.dwMinorVersion,
|
||||||
|
versioninfo.dwBuildNumber,
|
||||||
|
versioninfo.dwPlatformId,
|
||||||
|
versioninfo.szCSDVersion );
|
||||||
|
} else {
|
||||||
*info = '\0';
|
*info = '\0';
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int ret_code;
|
int ret_code;
|
||||||
struct utsname sys_info;
|
struct utsname sys_info;
|
||||||
@ -2369,9 +2349,10 @@ get_sdk_info( OUT char *info )
|
|||||||
if( ret_code == -1 ) {
|
if( ret_code == -1 ) {
|
||||||
*info = '\0';
|
*info = '\0';
|
||||||
}
|
}
|
||||||
|
sprintf( info,
|
||||||
sprintf( info, "%s/%s, UPnP/1.0, Portable SDK for UPnP devices/"
|
"%s/%s, UPnP/1.0, Portable SDK for UPnP devices/"PACKAGE_VERSION "\r\n",
|
||||||
PACKAGE_VERSION "\r\n",
|
sys_info.sysname,
|
||||||
sys_info.sysname, sys_info.release );
|
sys_info.release );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ http_CancelHttpGet( IN void *Handle );
|
|||||||
* IN uri_type* url; URL to be validated and fixed
|
* IN uri_type* url; URL to be validated and fixed
|
||||||
* OUT uri_type* fixed_url; URL after being fixed.
|
* OUT uri_type* fixed_url; URL after being fixed.
|
||||||
*
|
*
|
||||||
* Description: Validates URL
|
* Description:
|
||||||
|
* Validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@ -64,6 +65,7 @@ http_CancelHttpGet( IN void *Handle );
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_FixUrl( IN uri_type* url, OUT uri_type* fixed_url );
|
int http_FixUrl( IN uri_type* url, OUT uri_type* fixed_url );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_FixStrUrl
|
* Function: http_FixStrUrl
|
||||||
*
|
*
|
||||||
@ -72,7 +74,8 @@ int http_FixUrl( IN uri_type* url, OUT uri_type* fixed_url );
|
|||||||
* IN int urlstrlen ; Length of the character string
|
* IN int urlstrlen ; Length of the character string
|
||||||
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
* OUT uri_type* fixed_url ; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Parses URL and then validates URL
|
* Description:
|
||||||
|
* Parses URL and then validates URL
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* UPNP_E_INVALID_URL
|
* UPNP_E_INVALID_URL
|
||||||
@ -88,8 +91,8 @@ int http_FixStrUrl( IN char* urlstr, IN int urlstrlen, OUT uri_type* fixed_url )
|
|||||||
* IN uri_type* destination_url; URL containing destination information
|
* IN uri_type* destination_url; URL containing destination information
|
||||||
* OUT uri_type *url; Fixed and corrected URL
|
* OUT uri_type *url; Fixed and corrected URL
|
||||||
*
|
*
|
||||||
* Description: Gets destination address from URL and then connects to the
|
* Description:
|
||||||
* remote end
|
* Gets destination address from URL and then connects to the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* socket descriptor on sucess
|
* socket descriptor on sucess
|
||||||
@ -98,19 +101,21 @@ int http_FixStrUrl( IN char* urlstr, IN int urlstrlen, OUT uri_type* fixed_url )
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_Connect( IN uri_type* destination_url, OUT uri_type *url );
|
int http_Connect( IN uri_type* destination_url, OUT uri_type *url );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RecvMessage
|
* Function: http_RecvMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info; Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* OUT http_parser_t* parser, HTTP parser object
|
* OUT http_parser_t* parser; HTTP parser object
|
||||||
* IN http_method_t request_method; HTTP request method
|
* IN http_method_t request_method; HTTP request method
|
||||||
* IN OUT int* timeout_secs; time out
|
* IN OUT int* timeout_secs; time out
|
||||||
* OUT int* http_error_code; HTTP error code returned
|
* OUT int* http_error_code; HTTP error code returned
|
||||||
*
|
*
|
||||||
* Description: Get the data on the socket and take actions based on the
|
* Description:
|
||||||
* read data to modify the parser objects buffer. If an error is reported
|
* Get the data on the socket and take actions based on the read data
|
||||||
* while parsing the data, the error code is passed in the http_errr_code
|
* to modify the parser objects buffer. If an error is reported while
|
||||||
|
* parsing the data, the error code is passed in the http_errr_code
|
||||||
* parameter
|
* parameter
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@ -131,7 +136,8 @@ int http_RecvMessage( IN SOCKINFO *info, OUT http_parser_t* parser,
|
|||||||
* IN OUT int * TimeOut ; time out value
|
* IN OUT int * TimeOut ; time out value
|
||||||
* IN const char* fmt, ... Pattern format to take actions upon
|
* IN const char* fmt, ... Pattern format to take actions upon
|
||||||
*
|
*
|
||||||
* Description: Sends a message to the destination based on the
|
* Description:
|
||||||
|
* Sends a message to the destination based on the
|
||||||
* IN const char* fmt parameter
|
* IN const char* fmt parameter
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 'f': arg = const char * file name
|
* 'f': arg = const char * file name
|
||||||
@ -148,9 +154,12 @@ int http_RecvMessage( IN SOCKINFO *info, OUT http_parser_t* parser,
|
|||||||
* UPNP_E_FILE_READ_ERROR
|
* UPNP_E_FILE_READ_ERROR
|
||||||
* UPNP_E_SUCCESS
|
* UPNP_E_SUCCESS
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_SendMessage( IN SOCKINFO *info, IN OUT int* timeout_secs,
|
int http_SendMessage(
|
||||||
|
IN SOCKINFO *info,
|
||||||
|
IN OUT int* timeout_secs,
|
||||||
IN const char* fmt, ... );
|
IN const char* fmt, ... );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_RequestAndResponse
|
* Function: http_RequestAndResponse
|
||||||
*
|
*
|
||||||
@ -163,7 +172,8 @@ int http_SendMessage( IN SOCKINFO *info, IN OUT int* timeout_secs,
|
|||||||
* IN int timeout_secs; time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT http_parser_t* response; Parser object to receive the repsonse
|
* OUT http_parser_t* response; Parser object to receive the repsonse
|
||||||
*
|
*
|
||||||
* Description: Initiates socket, connects to the destination, sends a
|
* Description:
|
||||||
|
* Initiates socket, connects to the destination, sends a
|
||||||
* request and waits for the response from the remote end
|
* request and waits for the response from the remote end
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
@ -172,12 +182,15 @@ int http_SendMessage( IN SOCKINFO *info, IN OUT int* timeout_secs,
|
|||||||
* Error Codes returned by http_SendMessage
|
* Error Codes returned by http_SendMessage
|
||||||
* Error Codes returned by http_RecvMessage
|
* Error Codes returned by http_RecvMessage
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_RequestAndResponse( IN uri_type* destination,
|
int http_RequestAndResponse(
|
||||||
IN const char* request, IN size_t request_length,
|
IN uri_type* destination,
|
||||||
|
IN const char* request,
|
||||||
|
IN size_t request_length,
|
||||||
IN http_method_t req_method,
|
IN http_method_t req_method,
|
||||||
IN int timeout_secs,
|
IN int timeout_secs,
|
||||||
OUT http_parser_t* response );
|
OUT http_parser_t* response );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* return codes:
|
* return codes:
|
||||||
* 0 -- success
|
* 0 -- success
|
||||||
@ -190,30 +203,31 @@ int http_RequestAndResponse( IN uri_type* destination,
|
|||||||
* UPNP_E_SOCKET_WRITE
|
* UPNP_E_SOCKET_WRITE
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_Download
|
* Function: http_Download
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* url_str : String as a URL
|
* IN const char* url_str; String as a URL
|
||||||
* IN int timeout_secs : time out value
|
* IN int timeout_secs; time out value
|
||||||
* OUT char** document : buffer to store the document extracted
|
* OUT char** document; buffer to store the document extracted
|
||||||
* from the donloaded message.
|
* from the donloaded message.
|
||||||
* OUT int* doc_length : length of the extracted document
|
* OUT int* doc_length; length of the extracted document
|
||||||
* OUT char* content_type : Type of content
|
* OUT char* content_type; Type of content
|
||||||
*
|
*
|
||||||
* Description : Download the document message and extract the document
|
* Description:
|
||||||
|
* Download the document message and extract the document
|
||||||
* from the message.
|
* from the message.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS;
|
* UPNP_E_SUCCESS
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_Download( IN const char* url,
|
int http_Download(
|
||||||
|
IN const char* url,
|
||||||
IN int timeout_secs,
|
IN int timeout_secs,
|
||||||
OUT char** document, OUT int* doc_length,
|
OUT char** document,
|
||||||
|
OUT int* doc_length,
|
||||||
OUT char* content_type );
|
OUT char* content_type );
|
||||||
|
|
||||||
|
|
||||||
@ -227,67 +241,66 @@ int http_Download( IN const char* url,
|
|||||||
* IN unsigned int *size: Size of the data to be sent.
|
* IN unsigned int *size: Size of the data to be sent.
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Formats data if format used is UPNP_USING_CHUNKED.
|
* Description:
|
||||||
|
* Formats data if format used is UPNP_USING_CHUNKED.
|
||||||
* Writes data on the socket connected to the peer.
|
* Writes data on the socket connected to the peer.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* -1 - On Socket Error.
|
* -1 - On Socket Error.
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_WriteHttpPost(IN void *Handle,
|
int http_WriteHttpPost(IN void *Handle,
|
||||||
IN char *buf,
|
IN char *buf,
|
||||||
IN unsigned int *size,
|
IN unsigned int *size,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CloseHttpPost
|
* Function: http_CloseHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the http post object
|
* IN void *Handle; Handle to the http post object
|
||||||
* IN OUT int *httpStatus : HTTP status returned on receiving a
|
* IN OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Sends remaining data if using UPNP_USING_CHUNKED
|
* Description:
|
||||||
|
* Sends remaining data if using UPNP_USING_CHUNKED
|
||||||
* format. Receives any more messages. Destroys socket and any socket
|
* format. Receives any more messages. Destroys socket and any socket
|
||||||
* associated memory. Frees handle associated with the HTTP POST msg.
|
* associated memory. Frees handle associated with the HTTP POST msg.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_CloseHttpPost(IN void *Handle,
|
int http_CloseHttpPost(IN void *Handle,
|
||||||
IN OUT int *httpStatus,
|
IN OUT int *httpStatus,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpPost
|
* Function: http_OpenHttpPost
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN const char *contentType : Type of content
|
* IN const char *contentType; Type of content
|
||||||
* IN int contentLength : length of content
|
* IN int contentLength; length of content
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP POST message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP POST message, connects to the peer,
|
||||||
* sends the HTTP POST request. Adds the post handle to buffer of
|
* sends the HTTP POST request. Adds the post handle to buffer of
|
||||||
* such handles
|
* such handles
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return : int;
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramter ;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_SOCKET_CONNECT ;
|
* UPNP_E_SOCKET_CONNECT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpPost(IN const char *url_str,
|
int http_OpenHttpPost(IN const char *url_str,
|
||||||
IN OUT void **Handle,
|
IN OUT void **Handle,
|
||||||
@ -295,69 +308,72 @@ int http_OpenHttpPost(IN const char *url_str,
|
|||||||
IN int contentLength,
|
IN int contentLength,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_ReadHttpGet
|
* Function: http_ReadHttpGet
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* IN OUT char *buf : Buffer to get the read and parsed data
|
* IN OUT char *buf; Buffer to get the read and parsed data
|
||||||
* IN OUT unsigned int *size : Size of tge buffer passed
|
* IN OUT unsigned int *size; Size of the buffer passed
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Parses already existing data, then gets new data.
|
* Description:
|
||||||
|
* Parses already existing data, then gets new data.
|
||||||
* Parses and extracts information from the new data.
|
* Parses and extracts information from the new data.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
* UPNP_E_BAD_HTTPMSG ;
|
* UPNP_E_BAD_HTTPMSG
|
||||||
*
|
* UPNP_E_CANCELED
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_ReadHttpGet(IN void *Handle,
|
int http_ReadHttpGet(
|
||||||
|
IN void *Handle,
|
||||||
IN OUT char *buf,
|
IN OUT char *buf,
|
||||||
IN OUT unsigned int *size,
|
IN OUT unsigned int *size,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_HttpGetProgress
|
* Function: http_HttpGetProgress
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle : Handle to the HTTP get object
|
* IN void *Handle; Handle to the HTTP get object
|
||||||
* OUT unsigned int *length : Buffer to get the read and parsed data
|
* OUT unsigned int *length; Buffer to get the read and parsed data
|
||||||
* OUT unsigned int *total : Size of tge buffer passed
|
* OUT unsigned int *total; Size of tge buffer passed
|
||||||
*
|
*
|
||||||
* Description : Extracts information from the Handle to the HTTP get
|
* Description:
|
||||||
* object.
|
* Extracts information from the Handle to the HTTP get object.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Sucess ;
|
* UPNP_E_SUCCESS - On Sucess
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter;
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_HttpGetProgress(IN void *Handle,
|
int http_HttpGetProgress(
|
||||||
|
IN void *Handle,
|
||||||
OUT unsigned int *length,
|
OUT unsigned int *length,
|
||||||
OUT unsigned int *total );
|
OUT unsigned int *total );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CloseHttpGet
|
* Function: http_CloseHttpGet
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN void *Handle; Handle to HTTP get object
|
* IN void *Handle; Handle to HTTP get object
|
||||||
*
|
*
|
||||||
* Description : Clears the handle allocated for the HTTP GET operation
|
* Description:
|
||||||
|
* Clears the handle allocated for the HTTP GET operation
|
||||||
* Clears socket states and memory allocated for socket operations.
|
* Clears socket states and memory allocated for socket operations.
|
||||||
*
|
*
|
||||||
* Return : int ;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
* UPNP_E_INVALID_PARAM - Invalid Parameter
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_CloseHttpGet(IN void *Handle);
|
int http_CloseHttpGet(IN void *Handle);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpGet
|
* Function: http_OpenHttpGet
|
||||||
*
|
*
|
||||||
@ -371,54 +387,52 @@ int http_CloseHttpGet(IN void *Handle);
|
|||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpGet(IN const char *url_str,
|
int http_OpenHttpGet(
|
||||||
|
IN const char *url_str,
|
||||||
IN OUT void **Handle,
|
IN OUT void **Handle,
|
||||||
IN OUT char **contentType,
|
IN OUT char **contentType,
|
||||||
OUT int *contentLength,
|
OUT int *contentLength,
|
||||||
OUT int *httpStatus,
|
OUT int *httpStatus,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpGetProxy
|
* Function: http_OpenHttpGetProxy
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN const char *proxy_str : String as a URL to the proxy
|
* IN const char *proxy_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout: time out value
|
* IN int timeout: time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* response.
|
* sends the HTTP GET request, gets the response and parses the response.
|
||||||
*
|
* If a proxy URL is defined then the connection is made there.
|
||||||
* Return : int;
|
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
*
|
||||||
|
* Return: int
|
||||||
|
* UPNP_E_SUCCESS - On Success
|
||||||
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
|
* UPNP_E_OUTOF_MEMORY
|
||||||
|
* UPNP_E_SOCKET_ERROR
|
||||||
|
* UPNP_E_BAD_RESPONSE
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpGetProxy(IN const char *url_str,
|
int http_OpenHttpGetProxy(IN const char *url_str,
|
||||||
IN const char *proxy_str,
|
IN const char *proxy_str,
|
||||||
@ -433,24 +447,25 @@ int http_OpenHttpGetProxy(IN const char *url_str,
|
|||||||
* Function: http_SendStatusResponse
|
* Function: http_SendStatusResponse
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN SOCKINFO *info : Socket information object
|
* IN SOCKINFO *info; Socket information object
|
||||||
* IN int http_status_code : error code returned while making
|
* IN int http_status_code; error code returned while making
|
||||||
* or sending the response message
|
* or sending the response message
|
||||||
* IN int request_major_version : request major version
|
* IN int request_major_version; request major version
|
||||||
* IN int request_minor_version : request minor version
|
* IN int request_minor_version; request minor version
|
||||||
*
|
*
|
||||||
* Description : Generate a response message for the status query and
|
* Description:
|
||||||
* send the status response.
|
* Generate a response message for the status query and send the
|
||||||
|
* status response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 -- success
|
* 0 -- success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_WRITE
|
* UPNP_E_SOCKET_WRITE
|
||||||
* UPNP_E_TIMEDOUT
|
* UPNP_E_TIMEDOUT
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_SendStatusResponse( IN SOCKINFO *info, IN int http_status_code,
|
int http_SendStatusResponse(
|
||||||
|
IN SOCKINFO *info,
|
||||||
|
IN int http_status_code,
|
||||||
IN int request_major_version,
|
IN int request_major_version,
|
||||||
IN int request_minor_version );
|
IN int request_minor_version );
|
||||||
|
|
||||||
@ -459,96 +474,103 @@ int http_SendStatusResponse( IN SOCKINFO *info, IN int http_status_code,
|
|||||||
* Function: http_MakeMessage
|
* Function: http_MakeMessage
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* INOUT membuffer* buf : buffer with the contents of the
|
* INOUT membuffer* buf; buffer with the contents of the
|
||||||
* message
|
* message
|
||||||
* IN int http_major_version : HTTP major version
|
* IN int http_major_version; HTTP major version
|
||||||
* IN int http_minor_version : HTTP minor version
|
* IN int http_minor_version; HTTP minor version
|
||||||
* IN const char* fmt : Pattern format
|
* IN const char* fmt; Pattern format
|
||||||
* ... :
|
* ...;
|
||||||
*
|
*
|
||||||
* Description : Generate an HTTP message based on the format that is
|
* Description:
|
||||||
* specified in the input parameters.
|
* Generate an HTTP message based on the format that is specified
|
||||||
|
* in the input parameters.
|
||||||
*
|
*
|
||||||
* fmt types:
|
* fmt types:
|
||||||
* 's': arg = const char* C_string
|
* 'B': arg = int status_code
|
||||||
* 'b': arg1 = const char* buf; arg2 = size_t buf_length
|
* appends content-length, content-type and HTML body
|
||||||
* memory ptr
|
* for given code
|
||||||
* 'c': (no args) appends CRLF "\r\n"
|
* 'b': arg1 = const char* buf;
|
||||||
* 'd': arg = int number // appends decimal number
|
* arg2 = size_t buf_length memory ptr
|
||||||
* 'h': arg = off_t number // appends off_t number
|
|
||||||
* 't': arg = time_t * gmt_time // appends time in RFC 1123 fmt
|
|
||||||
* 'D': (no args) appends HTTP DATE: header
|
|
||||||
* 'S': (no args) appends HTTP SERVER: header
|
|
||||||
* 'U': (no args) appends HTTP USER-AGENT: header
|
|
||||||
* 'C': (no args) appends a HTTP CONNECTION: close header
|
* 'C': (no args) appends a HTTP CONNECTION: close header
|
||||||
* depending on major,minor version
|
* depending on major,minor version
|
||||||
* 'N': arg1 = int content_length // content-length header
|
* 'c': (no args) appends CRLF "\r\n"
|
||||||
* 'Q': arg1 = http_method_t; arg2 = char* url;
|
* 'D': (no args) appends HTTP DATE: header
|
||||||
* arg3 = int url_length // start line of request
|
* 'd': arg = int number // appends decimal number
|
||||||
|
* 'G': arg = range information // add range header
|
||||||
|
* 'h': arg = off_t number // appends off_t number
|
||||||
|
* 'K': (no args) // add chunky header
|
||||||
|
* 'N': arg1 = off_t content_length // content-length header
|
||||||
|
* 'q': arg1 = http_method_t // request start line and HOST header
|
||||||
|
* arg2 = (uri_type *)
|
||||||
|
* 'Q': arg1 = http_method_t; // start line of request
|
||||||
|
* arg2 = char* url;
|
||||||
|
* arg3 = size_t url_length
|
||||||
* 'R': arg = int status_code // adds a response start line
|
* 'R': arg = int status_code // adds a response start line
|
||||||
* 'B': arg = int status_code
|
* 'S': (no args) appends HTTP SERVER: header
|
||||||
* appends content-length, content-type and HTML body for given code
|
* 's': arg = const char* C_string
|
||||||
* 'T': arg = char * content_type; format e.g: "text/html";
|
* 'T': arg = char * content_type; format
|
||||||
* content-type header
|
* e.g: "text/html"; content-type header
|
||||||
|
* 't': arg = time_t * gmt_time // appends time in RFC 1123 fmt
|
||||||
|
* 'U': (no args) appends HTTP USER-AGENT: header
|
||||||
|
* 'X': arg = const char useragent; "redsonic" HTTP X-User-Agent: useragent
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* 0 - On Success
|
* 0 - On Success
|
||||||
* UPNP_E_OUTOF_MEMORY
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_INVALID_URL;
|
* UPNP_E_INVALID_URL
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_MakeMessage( INOUT membuffer* buf,
|
int http_MakeMessage(
|
||||||
|
INOUT membuffer* buf,
|
||||||
IN int http_major_version,
|
IN int http_major_version,
|
||||||
IN int http_minor_version,
|
IN int http_minor_version,
|
||||||
IN const char* fmt, ... );
|
IN const char* fmt, ... );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_CalcResponseVersion
|
* Function: http_CalcResponseVersion
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN int request_major_vers : Request major version
|
* IN int request_major_vers; Request major version
|
||||||
* IN int request_minor_vers : Request minor version
|
* IN int request_minor_vers; Request minor version
|
||||||
* OUT int* response_major_vers : Response mojor version
|
* OUT int* response_major_vers; Response mojor version
|
||||||
* OUT int* response_minor_vers : Response minor version
|
* OUT int* response_minor_vers; Response minor version
|
||||||
*
|
*
|
||||||
* Description : Calculate HTTP response versions based on the request
|
* Description:
|
||||||
* versions.
|
* Calculate HTTP response versions based on the request versions.
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void http_CalcResponseVersion(
|
void http_CalcResponseVersion(
|
||||||
IN int request_major_vers, IN int request_minor_vers,
|
IN int request_major_vers,
|
||||||
OUT int* response_major_vers, OUT int* response_minor_vers );
|
IN int request_minor_vers,
|
||||||
|
OUT int* response_major_vers,
|
||||||
|
OUT int* response_minor_vers );
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: http_OpenHttpGetEx
|
* Function: http_OpenHttpGetEx
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char *url_str : String as a URL
|
* IN const char *url_str; String as a URL
|
||||||
* IN OUT void **Handle : Pointer to buffer to store HTTP
|
* IN OUT void **Handle; Pointer to buffer to store HTTP
|
||||||
* post handle
|
* post handle
|
||||||
* IN OUT char **contentType : Type of content
|
* IN OUT char **contentType; Type of content
|
||||||
* OUT int *contentLength : length of content
|
* OUT int *contentLength; length of content
|
||||||
* OUT int *httpStatus : HTTP status returned on receiving a
|
* OUT int *httpStatus; HTTP status returned on receiving a
|
||||||
* response message
|
* response message
|
||||||
* IN int timeout : time out value
|
* IN int timeout; time out value
|
||||||
*
|
*
|
||||||
* Description : Makes the HTTP GET message, connects to the peer,
|
* Description:
|
||||||
|
* Makes the HTTP GET message, connects to the peer,
|
||||||
* sends the HTTP GET request, gets the response and parses the
|
* sends the HTTP GET request, gets the response and parses the
|
||||||
* response.
|
* response.
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return: int
|
||||||
* UPNP_E_SUCCESS - On Success ;
|
* UPNP_E_SUCCESS - On Success
|
||||||
* UPNP_E_INVALID_PARAM - Invalid Paramters ;
|
* UPNP_E_INVALID_PARAM - Invalid Paramters
|
||||||
* UPNP_E_OUTOF_MEMORY ;
|
* UPNP_E_OUTOF_MEMORY
|
||||||
* UPNP_E_SOCKET_ERROR ;
|
* UPNP_E_SOCKET_ERROR
|
||||||
* UPNP_E_BAD_RESPONSE ;
|
* UPNP_E_BAD_RESPONSE
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
*
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int http_OpenHttpGetEx(IN const char *url_str,
|
int http_OpenHttpGetEx(IN const char *url_str,
|
||||||
IN OUT void **Handle,
|
IN OUT void **Handle,
|
||||||
@ -559,18 +581,18 @@ int http_OpenHttpGetEx(IN const char *url_str,
|
|||||||
IN int highRange,
|
IN int highRange,
|
||||||
IN int timeout);
|
IN int timeout);
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: get_sdk_info
|
* Function: get_sdk_info
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* OUT char *info ;
|
* OUT char *info; buffer to store the operating system information
|
||||||
*
|
*
|
||||||
* Description : Returns the server information for the operating
|
* Description:
|
||||||
* system
|
* Returns the server information for the operating system
|
||||||
*
|
*
|
||||||
* Return : void ;
|
* Return:
|
||||||
*
|
* UPNP_INLINE void
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void get_sdk_info( OUT char *info );
|
void get_sdk_info( OUT char *info );
|
||||||
|
|
||||||
@ -580,3 +602,4 @@ void get_sdk_info( OUT char *info );
|
|||||||
|
|
||||||
|
|
||||||
#endif // GENLIB_NET_HTTP_HTTPREADWRITE_H
|
#endif // GENLIB_NET_HTTP_HTTPREADWRITE_H
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user