@@ -1049,12 +1049,13 @@ internal static bool Supported
1049
1049
1050
1050
// Server API
1051
1051
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 )
1053
1054
{
1054
1055
// Return value.
1055
1056
fixed ( byte * pMemoryBlob = memoryBlob )
1056
1057
{
1057
- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1058
+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
1058
1059
long fixup = pMemoryBlob - ( byte * ) originalAddress ;
1059
1060
int index ;
1060
1061
@@ -1064,7 +1065,7 @@ internal static void GetUnknownHeaders(IDictionary<string, StringValues> unknown
1064
1065
HTTP_UNKNOWN_HEADER * pUnknownHeader = ( HTTP_UNKNOWN_HEADER * ) ( fixup + ( byte * ) request ->Headers . pUnknownHeaders ) ;
1065
1066
for ( index = 0 ; index < request ->Headers . UnknownHeaderCount ; index ++ )
1066
1067
{
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
1068
1069
// pRawValue will be null.
1069
1070
if ( pUnknownHeader ->pName != null && pUnknownHeader ->NameLength > 0 )
1070
1071
{
@@ -1093,7 +1094,7 @@ private static string GetKnownHeader(HTTP_REQUEST* request, long fixup, int head
1093
1094
string header = null ;
1094
1095
1095
1096
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
1097
1098
// pRawValue will point to empty string ("\0")
1098
1099
if ( pKnownHeader ->pRawValue != null )
1099
1100
{
@@ -1103,11 +1104,12 @@ private static string GetKnownHeader(HTTP_REQUEST* request, long fixup, int head
1103
1104
return header ;
1104
1105
}
1105
1106
1106
- internal static string GetKnownHeader ( byte [ ] memoryBlob , IntPtr originalAddress , int headerIndex )
1107
+ internal static string GetKnownHeader ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress , int headerIndex )
1107
1108
{
1108
1109
fixed ( byte * pMemoryBlob = memoryBlob )
1109
1110
{
1110
- return GetKnownHeader ( ( HTTP_REQUEST * ) pMemoryBlob , pMemoryBlob - ( byte * ) originalAddress , headerIndex ) ;
1111
+ return GetKnownHeader (
1112
+ ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) , pMemoryBlob - ( byte * ) originalAddress , headerIndex ) ;
1111
1113
}
1112
1114
}
1113
1115
@@ -1127,21 +1129,21 @@ private static unsafe string GetVerb(HTTP_REQUEST* request, long fixup)
1127
1129
return verb ;
1128
1130
}
1129
1131
1130
- internal static unsafe string GetVerb ( byte [ ] memoryBlob , IntPtr originalAddress )
1132
+ internal static unsafe string GetVerb ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
1131
1133
{
1132
1134
fixed ( byte * pMemoryBlob = memoryBlob )
1133
1135
{
1134
- return GetVerb ( ( HTTP_REQUEST * ) pMemoryBlob , pMemoryBlob - ( byte * ) originalAddress ) ;
1136
+ return GetVerb ( ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) , pMemoryBlob - ( byte * ) originalAddress ) ;
1135
1137
}
1136
1138
}
1137
1139
1138
- internal static HTTP_VERB GetKnownVerb ( byte [ ] memoryBlob , IntPtr originalAddress )
1140
+ internal static HTTP_VERB GetKnownVerb ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
1139
1141
{
1140
1142
// Return value.
1141
1143
HTTP_VERB verb = HTTP_VERB . HttpVerbUnknown ;
1142
1144
fixed ( byte * pMemoryBlob = memoryBlob )
1143
1145
{
1144
- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1146
+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
1145
1147
if ( ( int ) request ->Verb > ( int ) HTTP_VERB . HttpVerbUnparsed && ( int ) request ->Verb < ( int ) HTTP_VERB . HttpVerbMaximum )
1146
1148
{
1147
1149
verb = request ->Verb ;
@@ -1151,13 +1153,14 @@ internal static HTTP_VERB GetKnownVerb(byte[] memoryBlob, IntPtr originalAddress
1151
1153
return verb ;
1152
1154
}
1153
1155
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 )
1155
1158
{
1156
1159
// Return value.
1157
1160
uint dataRead = 0 ;
1158
1161
fixed ( byte * pMemoryBlob = memoryBlob )
1159
1162
{
1160
- HTTP_REQUEST * request = ( HTTP_REQUEST * ) pMemoryBlob ;
1163
+ HTTP_REQUEST * request = ( HTTP_REQUEST * ) ( pMemoryBlob + requestOffset ) ;
1161
1164
long fixup = pMemoryBlob - ( byte * ) originalAddress ;
1162
1165
1163
1166
if ( request ->EntityChunkCount > 0 && dataChunkIndex < request ->EntityChunkCount && dataChunkIndex != - 1 )
@@ -1205,30 +1208,30 @@ internal static uint GetChunks(byte[] memoryBlob, IntPtr originalAddress, ref in
1205
1208
return dataRead ;
1206
1209
}
1207
1210
1208
- internal static SocketAddress GetRemoteEndPoint ( byte [ ] memoryBlob , IntPtr originalAddress )
1211
+ internal static SocketAddress GetRemoteEndPoint ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
1209
1212
{
1210
1213
fixed ( byte * pMemoryBlob = memoryBlob )
1211
1214
{
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 ) ;
1214
1217
}
1215
1218
}
1216
1219
1217
- internal static SocketAddress GetLocalEndPoint ( byte [ ] memoryBlob , IntPtr originalAddress )
1220
+ internal static SocketAddress GetLocalEndPoint ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress )
1218
1221
{
1219
1222
fixed ( byte * pMemoryBlob = memoryBlob )
1220
1223
{
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 ) ;
1223
1226
}
1224
1227
}
1225
1228
1226
- internal static SocketAddress GetEndPoint ( byte [ ] memoryBlob , IntPtr originalAddress , byte * source )
1229
+ internal static SocketAddress GetEndPoint ( byte [ ] memoryBlob , int requestOffset , IntPtr originalAddress , byte * source )
1227
1230
{
1228
1231
fixed ( byte * pMemoryBlob = memoryBlob )
1229
1232
{
1230
1233
IntPtr address = source != null ?
1231
- ( IntPtr ) ( pMemoryBlob - ( byte * ) originalAddress + source ) : IntPtr . Zero ;
1234
+ ( IntPtr ) ( pMemoryBlob + requestOffset - ( byte * ) originalAddress + source ) : IntPtr . Zero ;
1232
1235
return CopyOutAddress ( address ) ;
1233
1236
}
1234
1237
}
0 commit comments