Further regecp refinements.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@985 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2004-03-19 11:13:47 +00:00
parent 899c9999d4
commit 3411f10f82
1 changed files with 7 additions and 7 deletions

View File

@ -279,7 +279,7 @@ int RemoteCamera::GetResponse()
Debug( 4, ( "Captured header (%d bytes):\n'%s'", header_len, header )); Debug( 4, ( "Captured header (%d bytes):\n'%s'", header_len, header ));
if ( !status_expr ) if ( !status_expr )
status_expr = new RegExpr( "^HTTP/(1\\.[01]) +([0-9]+) +(.+?)\r?\n", PCRE_MULTILINE|PCRE_CASELESS ); status_expr = new RegExpr( "^HTTP/(1\\.[01]) +([0-9]+) +(.+?)\r?\n", PCRE_CASELESS );
if ( status_expr->Match( header, header_len ) < 4 ) if ( status_expr->Match( header, header_len ) < 4 )
{ {
Error(( "Unable to extract HTTP status from header" )); Error(( "Unable to extract HTTP status from header" ));
@ -369,8 +369,8 @@ int RemoteCamera::GetResponse()
if ( !subheader_expr ) if ( !subheader_expr )
{ {
char subheader_pattern[256] = ""; char subheader_pattern[256] = "";
sprintf( subheader_pattern, "^((?:\r?\n\r?\n)?(?:--)?%s\r?\n.+?\r?\n\r?\n)", content_boundary ); sprintf( subheader_pattern, "^((?:\r?\n){0,2}?(?:--)?%s\r?\n.+?\r?\n\r?\n)", content_boundary );
subheader_expr = new RegExpr( subheader_pattern, PCRE_MULTILINE|PCRE_DOTALL ); subheader_expr = new RegExpr( subheader_pattern, PCRE_DOTALL );
} }
if ( subheader_expr->Match( (char *)buffer, (int)buffer ) == 2 ) if ( subheader_expr->Match( (char *)buffer, (int)buffer ) == 2 )
{ {
@ -442,7 +442,7 @@ int RemoteCamera::GetResponse()
static RegExpr *single_jpeg_expr = 0; static RegExpr *single_jpeg_expr = 0;
if ( !content_expr ) if ( !content_expr )
{ {
content_expr = new RegExpr( "^(.+?)\r?\n\r?\n$", PCRE_MULTILINE|PCRE_DOTALL ); content_expr = new RegExpr( "^(.+?)(?:\r?\n){1,2}?$", PCRE_DOTALL );
} }
} }
else else
@ -451,8 +451,8 @@ int RemoteCamera::GetResponse()
if ( !content_expr ) if ( !content_expr )
{ {
char content_pattern[256] = ""; char content_pattern[256] = "";
sprintf( content_pattern, "^(.+?)\r?\n\r?\n(?:--)?%s\r?\n", content_boundary ); sprintf( content_pattern, "^(.+?)(?:\r?\n){1,2}?(?:--)?%s\r?\n", content_boundary );
content_expr = new RegExpr( content_pattern, PCRE_MULTILINE|PCRE_DOTALL ); content_expr = new RegExpr( content_pattern, PCRE_DOTALL );
} }
} }
if ( content_expr->Match( buffer, buffer.Size() ) == 2 ) if ( content_expr->Match( buffer, buffer.Size() ) == 2 )
@ -471,7 +471,7 @@ int RemoteCamera::GetResponse()
{ {
state = SUBHEADER; state = SUBHEADER;
} }
Debug( 3, ( "Returning %d bytes of captured content", content_length )); Debug( 3, ( "Returning %d (%d) bytes of captured content", content_length, buffer.Size() ));
return( content_length ); return( content_length );
} }
} }