Merge of trunk into branch-1.4.x.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.4.x@127 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez
2007-02-03 19:30:31 +00:00
parent 9e775e662e
commit 8cfa0e488c
29 changed files with 874 additions and 443 deletions

View File

@@ -632,7 +632,7 @@ get_file_info( IN const char *filename,
rc = get_content_type( filename, &info->content_type );
DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
"file info: %s, length: %d, last_mod=%s readable=%d\n",
"file info: %s, length: %lld, last_mod=%s readable=%d\n",
filename, info->file_length,
asctime( gmtime( &info->last_modified ) ),
info->is_readable ); )
@@ -871,8 +871,8 @@ StrTok( char **Src,
************************************************************************/
int
GetNextRange( char **SrcRangeStr,
int *FirstByte,
int *LastByte )
off_t *FirstByte,
off_t *LastByte )
{
char *Ptr,
*Tok;
@@ -936,11 +936,11 @@ GetNextRange( char **SrcRangeStr,
************************************************************************/
int
CreateHTTPRangeResponseHeader( char *ByteRangeSpecifier,
long FileLength,
off_t FileLength,
OUT struct SendInstruction *Instr )
{
int FirstByte,
off_t FirstByte,
LastByte;
char *RangeInput,
*Ptr;
@@ -984,26 +984,26 @@ CreateHTTPRangeResponseHeader( char *ByteRangeSpecifier,
Instr->RangeOffset = FirstByte;
Instr->ReadSendSize = LastByte - FirstByte + 1;
sprintf( Instr->RangeHeader, "CONTENT-RANGE: bytes %d-%d/%ld\r\n", FirstByte, LastByte, FileLength ); //Data between two range.
sprintf( Instr->RangeHeader, "CONTENT-RANGE: bytes %lld-%lld/%lld\r\n", FirstByte, LastByte, FileLength ); //Data between two range.
} else if( FirstByte >= 0 && LastByte == -1
&& FirstByte < FileLength ) {
Instr->RangeOffset = FirstByte;
Instr->ReadSendSize = FileLength - FirstByte;
sprintf( Instr->RangeHeader,
"CONTENT-RANGE: bytes %d-%ld/%ld\r\n", FirstByte,
"CONTENT-RANGE: bytes %lld-%lld/%lld\r\n", FirstByte,
FileLength - 1, FileLength );
} else if( FirstByte == -1 && LastByte > 0 ) {
if( LastByte >= FileLength ) {
Instr->RangeOffset = 0;
Instr->ReadSendSize = FileLength;
sprintf( Instr->RangeHeader,
"CONTENT-RANGE: bytes 0-%ld/%ld\r\n",
"CONTENT-RANGE: bytes 0-%lld/%lld\r\n",
FileLength - 1, FileLength );
} else {
Instr->RangeOffset = FileLength - LastByte;
Instr->ReadSendSize = LastByte;
sprintf( Instr->RangeHeader,
"CONTENT-RANGE: bytes %ld-%ld/%ld\r\n",
"CONTENT-RANGE: bytes %lld-%lld/%lld\r\n",
FileLength - LastByte + 1, FileLength,
FileLength );
}
@@ -1042,7 +1042,7 @@ CreateHTTPRangeResponseHeader( char *ByteRangeSpecifier,
int
CheckOtherHTTPHeaders( IN http_message_t * Req,
OUT struct SendInstruction *RespInstr,
int FileSize )
off_t FileSize )
{
http_header_t *header;
ListNode *node;
@@ -1184,7 +1184,6 @@ process_request( IN http_message_t * req,
int code;
int err_code;
//membuffer content_type;
char *request_doc;
struct File_Info finfo;
xboolean using_alias;
@@ -1208,7 +1207,6 @@ process_request( IN http_message_t * req,
// init
request_doc = NULL;
finfo.content_type = NULL;
//membuffer_init( &content_type );
alias_grabbed = FALSE;
err_code = HTTP_INTERNAL_SERVER_ERROR; // default error
using_virtual_dir = FALSE;
@@ -1362,7 +1360,7 @@ process_request( IN http_message_t * req,
RespInstr->ReadSendSize = finfo.file_length;
//Check other header field.
// Check other header field.
if( ( err_code =
CheckOtherHTTPHeaders( req, RespInstr,
finfo.file_length ) ) != HTTP_OK ) {
@@ -1376,85 +1374,80 @@ process_request( IN http_message_t * req,
}
if( RespInstr->IsRangeActive && RespInstr->IsChunkActive ) {
/* - PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net>
* added X-User-Agent header
*/
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
//Transfer-Encoding: chunked
// K means add chunky header ang G means range header.
if( http_MakeMessage( headers, resp_major, resp_minor, "RTGKDstcSXcCc", HTTP_PARTIAL_CONTENT, // status code
// RespInstr->ReadSendSize,// content length
finfo.content_type,
// content_type.buf, // content type
RespInstr, // Range
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "T" "GKD" "s" "tcS" "XcCc",
HTTP_PARTIAL_CONTENT, // status code
finfo.content_type, // content type
RespInstr, // range info
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
goto error_handler;
}
} else if( RespInstr->IsRangeActive && !RespInstr->IsChunkActive ) {
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
//Transfer-Encoding: chunked
// K means add chunky header ang G means range header.
if( http_MakeMessage( headers, resp_major, resp_minor, "RNTGDstcSXcCc", HTTP_PARTIAL_CONTENT, // status code
RespInstr->ReadSendSize, // content length
finfo.content_type,
//content_type.buf, // content type
RespInstr, //Range Info
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "N" "T" "GD" "s" "tcS" "XcCc",
HTTP_PARTIAL_CONTENT, // status code
RespInstr->ReadSendSize, // content length
finfo.content_type, // content type
RespInstr, // range info
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
goto error_handler;
}
} else if( !RespInstr->IsRangeActive && RespInstr->IsChunkActive ) {
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
//Transfer-Encoding: chunked
// K means add chunky header ang G means range header.
if( http_MakeMessage( headers, resp_major, resp_minor, "RKTDstcSXcCc", HTTP_OK, // status code
//RespInstr->ReadSendSize,// content length
finfo.content_type,
// content_type.buf, // content type
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"RK" "TD" "s" "tcS" "XcCc",
HTTP_OK, // status code
finfo.content_type, // content type
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
goto error_handler;
}
} else {
if( RespInstr->ReadSendSize >= 0 ) {
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
//Transfer-Encoding: chunked
// K means add chunky header ang G means range header.
if( http_MakeMessage( headers, resp_major, resp_minor, "RNTDstcSXcCc", HTTP_OK, // status code
RespInstr->ReadSendSize, // content length
finfo.content_type,
//content_type.buf, // content type
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
} else { // !RespInstr->IsRangeActive && !RespInstr->IsChunkActive
if (RespInstr->ReadSendSize >= 0) {
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "N" "TD" "s" "tcS" "XcCc",
HTTP_OK, // status code
RespInstr->ReadSendSize, // content length
finfo.content_type, // content type
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
goto error_handler;
}
} else {
//Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
//Transfer-Encoding: chunked
// K means add chunky header ang G means range header.
if( http_MakeMessage( headers, resp_major, resp_minor, "RTDstcSXcCc", HTTP_OK, // status code
//RespInstr->ReadSendSize,// content length
finfo.content_type,
//content_type.buf, // content type
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
// Content-Range: bytes 222-3333/4000 HTTP_PARTIAL_CONTENT
// Transfer-Encoding: chunked
if (http_MakeMessage(
headers, resp_major, resp_minor,
"R" "TD" "s" "tcS" "XcCc",
HTTP_OK, // status code
finfo.content_type, // content type
"LAST-MODIFIED: ",
&finfo.last_modified,
X_USER_AGENT) != 0 ) {
goto error_handler;
}
}
}
/* -- PATCH END -- */
if( req->method == HTTPMETHOD_HEAD ) {
*rtype = RESP_HEADERS;
@@ -1468,8 +1461,8 @@ process_request( IN http_message_t * req,
*rtype = RESP_FILEDOC;
}
//simple get http 0.9 as specified in http 1.0
//don't send headers
// simple get http 0.9 as specified in http 1.0
// don't send headers
if( req->method == HTTPMETHOD_SIMPLEGET ) {
membuffer_destroy( headers );
}
@@ -1479,7 +1472,6 @@ process_request( IN http_message_t * req,
error_handler:
free( request_doc );
ixmlFreeDOMString( finfo.content_type );
// membuffer_destroy( &content_type );
if( err_code != UPNP_E_SUCCESS && alias_grabbed ) {
alias_release( alias );
}
@@ -1738,12 +1730,12 @@ web_server_callback( IN http_parser_t * parser,
&RespInstr );
//Send response.
/* - PATCH START - Sergey 'Jin' Bostandzhyan <jin_eld at users.sourceforge.net>
* added X-User-Agent header
*/
http_MakeMessage( &headers, 1, 1, "RTDSXcCc", ret,
"text/html", X_USER_AGENT );
/* - PATCH END --- */
http_MakeMessage(
&headers, 1, 1,
"RTDSXcCc",
ret,
"text/html",
X_USER_AGENT );
http_SendMessage( info, &timeout, "b", headers.buf,
headers.length );