View | Details | Raw Unified | Return to bug 33622
Collapse All | Expand All

(-)message.py (-9 / +8 lines)
 Lines 190-199    Link Here 
190
190
191
		:raises: :class:`.ParseError`, :class:`.UnknownCommandError`, :class:`.InvalidArgumentsError`
191
		:raises: :class:`.ParseError`, :class:`.UnknownCommandError`, :class:`.InvalidArgumentsError`
192
		"""
192
		"""
193
		lines = msg.split( '\n', 1 )
193
		header, nl, body = msg.partition('\n')
194
194
195
		# is the format of the header line valid?
195
		# is the format of the header line valid?
196
		match = Message._header.match( lines[ 0 ] )
196
		match = Message._header.match(header)
197
		if not match:
197
		if not match:
198
			raise ParseError( UMCP_ERR_UNPARSABLE_HEADER, _( 'Unparsable message header' ) )
198
			raise ParseError( UMCP_ERR_UNPARSABLE_HEADER, _( 'Unparsable message header' ) )
199
199
 Lines 224-241    Link Here 
224
				raise InvalidArgumentsError( UMCP_ERR_ARGS_MISSMATCH, _( "The command '%s' do not have any arguments" ) % self.command )
224
				raise InvalidArgumentsError( UMCP_ERR_ARGS_MISSMATCH, _( "The command '%s' do not have any arguments" ) % self.command )
225
225
226
		# invalid/missing message body?
226
		# invalid/missing message body?
227
		current_length = len( lines[ 1 ] )
227
		current_length = len(body)
228
		if len( lines ) < 2 or self._length > current_length:
228
		if not body or self._length > current_length:
229
			PARSER.info( 'The message body is not complete: %d of %d bytes' % ( current_length, self._length ) )
229
			PARSER.info( 'The message body is not complete: %d of %d bytes' % ( current_length, self._length ) )
230
			raise IncompleteMessageError( _( 'The message body is not (yet) complete' ) )
230
			raise IncompleteMessageError( _( 'The message body is not (yet) complete' ) )
231
231
232
		remains = ''
232
		remains = ''
233
		if len( lines[ 1 ] ) > self._length:
233
		if len(body) > self._length:
234
			remains = lines[ 1 ][ self._length : ]
234
			remains = body[ self._length : ]
235
		if len( lines[ 1 ] ) > self._length:
235
			self.body = body[ : self._length ]
236
			self.body = lines[ 1 ][ : self._length ]
237
		else:
236
		else:
238
			self.body = lines[ 1 ]
237
			self.body = body
239
238
240
		if self.mimetype == MIMETYPE_JSON:
239
		if self.mimetype == MIMETYPE_JSON:
241
			try:
240
			try:

Return to bug 33622