mirror of https://github.com/apache/activemq.git
Allows the stomp client to accept a variable amount of while space between frames.
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@419004 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9324b597ac
commit
399981fe74
|
@ -70,20 +70,46 @@ Command* StompCommandReader::readCommand(void)
|
|||
void StompCommandReader::readStompCommand( StompFrame& frame )
|
||||
throw ( StompConnectorException )
|
||||
{
|
||||
// Read the command;
|
||||
int numChars = readStompHeaderLine();
|
||||
|
||||
if( numChars <= 0 )
|
||||
while( true )
|
||||
{
|
||||
throw StompConnectorException(
|
||||
__FILE__, __LINE__,
|
||||
"StompCommandReader::readStompCommand: "
|
||||
"Error on Read of Command Header" );
|
||||
// Clean up the mess.
|
||||
buffer.clear();
|
||||
|
||||
// Read the command;
|
||||
readStompHeaderLine();
|
||||
|
||||
// Ignore all white space before the command.
|
||||
int offset=-1;
|
||||
for( size_t ix = 0; ix < buffer.size()-1; ++ix )
|
||||
{
|
||||
// Find the first non space character
|
||||
char b = buffer[ix];
|
||||
switch ( b )
|
||||
{
|
||||
case '\n':
|
||||
case '\t':
|
||||
case '\r':
|
||||
break;
|
||||
|
||||
default:
|
||||
offset = ix;
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the command in the frame - copy the memory.
|
||||
frame.setCommand( reinterpret_cast<char*>(&buffer[0]) );
|
||||
if( offset != -1 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( offset >= 0 )
|
||||
{
|
||||
// Set the command in the frame - copy the memory.
|
||||
frame.setCommand( reinterpret_cast<char*>(&buffer[offset]) );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// Clean up the mess.
|
||||
buffer.clear();
|
||||
}
|
||||
|
@ -224,8 +250,7 @@ void StompCommandReader::readStompBody( StompFrame& frame )
|
|||
read( &buffer[0], content_length );
|
||||
|
||||
// Content Length read, now pop the end terminator off (\0\n).
|
||||
if(inputStream->read() != '\0' ||
|
||||
inputStream->read() != '\n')
|
||||
if(inputStream->read() != '\0' )
|
||||
{
|
||||
throw StompConnectorException(
|
||||
__FILE__, __LINE__,
|
||||
|
@ -251,16 +276,6 @@ void StompCommandReader::readStompBody( StompFrame& frame )
|
|||
continue;
|
||||
}
|
||||
|
||||
// We read up to the first NULL, now lets pop off the required
|
||||
// newline to complete the packet.
|
||||
if(inputStream->read() != '\n')
|
||||
{
|
||||
throw StompConnectorException(
|
||||
__FILE__, __LINE__,
|
||||
"StompCommandReader::readStompBody: "
|
||||
"Read Body, and no trailing newline");
|
||||
}
|
||||
|
||||
break; // Read null and newline we are done.
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue