@@ -77,51 +77,46 @@ public Command HandleFrame(InboundFrame f)
77
77
switch ( m_state )
78
78
{
79
79
case AssemblyState . ExpectingMethod :
80
+ if ( ! f . IsMethod ( ) )
80
81
{
81
- if ( ! f . IsMethod ( ) )
82
- {
83
- throw new UnexpectedFrameException ( f ) ;
84
- }
85
- m_method = m_protocol . DecodeMethodFrom ( f . Payload . AsMemory ( 0 , f . PayloadSize ) ) ;
86
- m_state = m_method . HasContent
87
- ? AssemblyState . ExpectingContentHeader
88
- : AssemblyState . Complete ;
89
- return CompletedCommand ( ) ;
82
+ throw new UnexpectedFrameException ( f ) ;
90
83
}
84
+ m_method = m_protocol . DecodeMethodFrom ( f . Payload . AsMemory ( 0 , f . PayloadSize ) ) ;
85
+ m_state = m_method . HasContent ? AssemblyState . ExpectingContentHeader : AssemblyState . Complete ;
86
+ return CompletedCommand ( ) ;
91
87
case AssemblyState . ExpectingContentHeader :
88
+ if ( ! f . IsHeader ( ) )
92
89
{
93
- if ( ! f . IsHeader ( ) )
94
- {
95
- throw new UnexpectedFrameException ( f ) ;
96
- }
97
- Memory < byte > memory = f . Payload . AsMemory ( 0 , f . PayloadSize ) ;
98
- m_header = m_protocol . DecodeContentHeaderFrom ( NetworkOrderDeserializer . ReadUInt16 ( memory ) ) ;
99
- ulong totalBodyBytes = m_header . ReadFrom ( memory . Slice ( 2 ) ) ;
100
- if ( totalBodyBytes > MaxArrayOfBytesSize )
101
- {
102
- throw new UnexpectedFrameException ( f ) ;
103
- }
104
- m_remainingBodyBytes = ( int ) totalBodyBytes ;
105
- m_body = new byte [ m_remainingBodyBytes ] ;
106
- m_bodyStream = new MemoryStream ( m_body , true ) ;
107
- UpdateContentBodyState ( ) ;
108
- return CompletedCommand ( ) ;
90
+ throw new UnexpectedFrameException ( f ) ;
109
91
}
92
+ Memory < byte > memory = f . Payload . AsMemory ( 0 , f . PayloadSize ) ;
93
+ m_header = m_protocol . DecodeContentHeaderFrom ( NetworkOrderDeserializer . ReadUInt16 ( memory ) ) ;
94
+ ulong totalBodyBytes = m_header . ReadFrom ( memory . Slice ( 2 ) ) ;
95
+ if ( totalBodyBytes > MaxArrayOfBytesSize )
96
+ {
97
+ throw new UnexpectedFrameException ( f ) ;
98
+ }
99
+
100
+ m_remainingBodyBytes = ( int ) totalBodyBytes ;
101
+ m_body = new byte [ m_remainingBodyBytes ] ;
102
+ m_bodyStream = new MemoryStream ( m_body , true ) ;
103
+ UpdateContentBodyState ( ) ;
104
+ return CompletedCommand ( ) ;
110
105
case AssemblyState . ExpectingContentBody :
106
+ if ( ! f . IsBody ( ) )
111
107
{
112
- if ( ! f . IsBody ( ) )
113
- {
114
- throw new UnexpectedFrameException ( f ) ;
115
- }
116
- if ( f . PayloadSize > m_remainingBodyBytes )
117
- {
118
- throw new MalformedFrameException ( $ "Overlong content body received - { m_remainingBodyBytes } bytes remaining, { f . PayloadSize } bytes received") ;
119
- }
120
- m_bodyStream . Write ( f . Payload , 0 , f . PayloadSize ) ;
121
- m_remainingBodyBytes -= f . PayloadSize ;
122
- UpdateContentBodyState ( ) ;
123
- return CompletedCommand ( ) ;
108
+ throw new UnexpectedFrameException ( f ) ;
124
109
}
110
+
111
+ if ( f . PayloadSize > m_remainingBodyBytes )
112
+ {
113
+ throw new MalformedFrameException ( $ "Overlong content body received - { m_remainingBodyBytes } bytes remaining, { f . PayloadSize } bytes received") ;
114
+ }
115
+
116
+ m_bodyStream . Write ( f . Payload , 0 , f . PayloadSize ) ;
117
+ m_remainingBodyBytes -= f . PayloadSize ;
118
+ UpdateContentBodyState ( ) ;
119
+ return CompletedCommand ( ) ;
125
120
case AssemblyState . Complete :
126
121
default :
127
122
return null ;
0 commit comments