@@ -1049,12 +1049,13 @@ internal static bool Supported
10491049
10501050 // Server API
10511051
1052- internal static void GetUnknownHeaders ( IDictionary < string , StringValues > unknownHeaders , byte [ ] memoryBlob , IntPtr originalAddress )
1052+ internal static void GetUnknownHeaders ( IDictionary < string , StringValues > unknownHeaders , byte [ ] memoryBlob ,
1053+ int requestOffset , IntPtr originalAddress )
10531054 {
10541055 // Return value.
10551056 fixed ( byte * pMemoryBlob = memoryBlob )
10561057 {
1057- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1058+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
10581059 long fixup = pMemoryBlob - ( byte * ) originalAddress ;
10591060 int index ;
10601061
@@ -1064,7 +1065,7 @@ internal static void GetUnknownHeaders(IDictionary<string, StringValues> unknown
10641065 HTTP_UNKNOWN_HEADER * pUnknownHeader = ( HTTP_UNKNOWN_HEADER * ) ( fixup + ( byte * ) request ->Headers . pUnknownHeaders ) ;
10651066 for ( index = 0 ; index < request ->Headers . UnknownHeaderCount ; index ++ )
10661067 {
1067- // For unknown headers, when header value is empty, RawValueLength will be 0 and
1068+ // For unknown headers, when header value is empty, RawValueLength will be 0 and
10681069 // pRawValue will be null.
10691070 if ( pUnknownHeader ->pName != null && pUnknownHeader ->NameLength > 0 )
10701071 {
@@ -1093,7 +1094,7 @@ private static string GetKnownHeader(HTTP_REQUEST* request, long fixup, int head
10931094 string header = null ;
10941095
10951096 HTTP_KNOWN_HEADER * pKnownHeader = ( & request ->Headers . KnownHeaders ) + headerIndex ;
1096- // For known headers, when header value is empty, RawValueLength will be 0 and
1097+ // For known headers, when header value is empty, RawValueLength will be 0 and
10971098 // pRawValue will point to empty string ("\0")
10981099 if ( pKnownHeader ->pRawValue != null )
10991100 {
@@ -1103,11 +1104,12 @@ private static string GetKnownHeader(HTTP_REQUEST* request, long fixup, int head
11031104 return header ;
11041105 }
11051106
1106- internal static string GetKnownHeader ( byte [ ] memoryBlob , IntPtr originalAddress , int headerIndex )
1107+ internal static string GetKnownHeader ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress , int headerIndex )
11071108 {
11081109 fixed ( byte * pMemoryBlob = memoryBlob )
11091110 {
1110- return GetKnownHeader ( ( HTTP_REQUEST * ) pMemoryBlob , pMemoryBlob - ( byte * ) originalAddress , headerIndex ) ;
1111+ return GetKnownHeader (
1112+ ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) , pMemoryBlob - ( byte * ) originalAddress , headerIndex ) ;
11111113 }
11121114 }
11131115
@@ -1127,21 +1129,21 @@ private static unsafe string GetVerb(HTTP_REQUEST* request, long fixup)
11271129 return verb ;
11281130 }
11291131
1130- internal static unsafe string GetVerb ( byte [ ] memoryBlob , IntPtr originalAddress )
1132+ internal static unsafe string GetVerb ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
11311133 {
11321134 fixed ( byte * pMemoryBlob = memoryBlob )
11331135 {
1134- return GetVerb ( ( HTTP_REQUEST * ) pMemoryBlob , pMemoryBlob - ( byte * ) originalAddress ) ;
1136+ return GetVerb ( ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) , pMemoryBlob - ( byte * ) originalAddress ) ;
11351137 }
11361138 }
11371139
1138- internal static HTTP_VERB GetKnownVerb ( byte [ ] memoryBlob , IntPtr originalAddress )
1140+ internal static HTTP_VERB GetKnownVerb ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
11391141 {
11401142 // Return value.
11411143 HTTP_VERB verb = HTTP_VERB . HttpVerbUnknown ;
11421144 fixed ( byte * pMemoryBlob = memoryBlob )
11431145 {
1144- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1146+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
11451147 if ( ( int ) request ->Verb > ( int ) HTTP_VERB . HttpVerbUnparsed && ( int ) request ->Verb < ( int ) HTTP_VERB . HttpVerbMaximum )
11461148 {
11471149 verb = request ->Verb ;
@@ -1151,13 +1153,14 @@ internal static HTTP_VERB GetKnownVerb(byte[] memoryBlob, IntPtr originalAddress
11511153 return verb ;
11521154 }
11531155
1154- internal static uint GetChunks ( byte [ ] memoryBlob , IntPtr originalAddress , ref int dataChunkIndex , ref uint dataChunkOffset , byte [ ] buffer , int offset , int size )
1156+ internal static uint GetChunks ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress ,
1157+ ref int dataChunkIndex , ref uint dataChunkOffset , byte [ ] buffer , int offset , int size )
11551158 {
11561159 // Return value.
11571160 uint dataRead = 0 ;
11581161 fixed ( byte * pMemoryBlob = memoryBlob )
11591162 {
1160- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1163+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
11611164 long fixup = pMemoryBlob - ( byte * ) originalAddress ;
11621165
11631166 if ( request ->EntityChunkCount > 0 && dataChunkIndex < request ->EntityChunkCount && dataChunkIndex != - 1 )
@@ -1205,30 +1208,30 @@ internal static uint GetChunks(byte[] memoryBlob, IntPtr originalAddress, ref in
12051208 return dataRead ;
12061209 }
12071210
1208- internal static SocketAddress GetRemoteEndPoint ( byte [ ] memoryBlob , IntPtr originalAddress )
1211+ internal static SocketAddress GetRemoteEndPoint ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
12091212 {
12101213 fixed ( byte * pMemoryBlob = memoryBlob )
12111214 {
1212- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1213- return GetEndPoint ( memoryBlob , originalAddress , ( byte * ) request ->Address . pRemoteAddress ) ;
1215+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
1216+ return GetEndPoint ( memoryBlob , requestOffset , originalAddress , ( byte * ) request ->Address . pRemoteAddress ) ;
12141217 }
12151218 }
12161219
1217- internal static SocketAddress GetLocalEndPoint ( byte [ ] memoryBlob , IntPtr originalAddress )
1220+ internal static SocketAddress GetLocalEndPoint ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
12181221 {
12191222 fixed ( byte * pMemoryBlob = memoryBlob )
12201223 {
1221- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1222- return GetEndPoint ( memoryBlob , originalAddress , ( byte * ) request ->Address . pLocalAddress ) ;
1224+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
1225+ return GetEndPoint ( memoryBlob , requestOffset , originalAddress , ( byte * ) request ->Address . pLocalAddress ) ;
12231226 }
12241227 }
12251228
1226- internal static SocketAddress GetEndPoint ( byte [ ] memoryBlob , IntPtr originalAddress , byte * source )
1229+ internal static SocketAddress GetEndPoint ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress , byte * source )
12271230 {
12281231 fixed ( byte * pMemoryBlob = memoryBlob )
12291232 {
12301233 IntPtr address = source != null ?
1231- ( IntPtr ) ( pMemoryBlob - ( byte * ) originalAddress + source ) : IntPtr . Zero ;
1234+ ( IntPtr ) ( pMemoryBlob + requestOffset - ( byte * ) originalAddress + source ) : IntPtr . Zero ;
12321235 return CopyOutAddress ( address ) ;
12331236 }
12341237 }
0 commit comments