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 )
|
void StompCommandReader::readStompCommand( StompFrame& frame )
|
||||||
throw ( StompConnectorException )
|
throw ( StompConnectorException )
|
||||||
{
|
{
|
||||||
// Read the command;
|
while( true )
|
||||||
int numChars = readStompHeaderLine();
|
{
|
||||||
|
// Clean up the mess.
|
||||||
|
buffer.clear();
|
||||||
|
|
||||||
if( numChars <= 0 )
|
// Read the command;
|
||||||
{
|
readStompHeaderLine();
|
||||||
throw StompConnectorException(
|
|
||||||
__FILE__, __LINE__,
|
|
||||||
"StompCommandReader::readStompCommand: "
|
|
||||||
"Error on Read of Command Header" );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the command in the frame - copy the memory.
|
|
||||||
frame.setCommand( reinterpret_cast<char*>(&buffer[0]) );
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
// Clean up the mess.
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
|
@ -224,8 +250,7 @@ void StompCommandReader::readStompBody( StompFrame& frame )
|
||||||
read( &buffer[0], content_length );
|
read( &buffer[0], content_length );
|
||||||
|
|
||||||
// Content Length read, now pop the end terminator off (\0\n).
|
// Content Length read, now pop the end terminator off (\0\n).
|
||||||
if(inputStream->read() != '\0' ||
|
if(inputStream->read() != '\0' )
|
||||||
inputStream->read() != '\n')
|
|
||||||
{
|
{
|
||||||
throw StompConnectorException(
|
throw StompConnectorException(
|
||||||
__FILE__, __LINE__,
|
__FILE__, __LINE__,
|
||||||
|
@ -251,16 +276,6 @@ void StompCommandReader::readStompBody( StompFrame& frame )
|
||||||
continue;
|
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.
|
break; // Read null and newline we are done.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue