File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,12 +37,29 @@ internal bool BadRequestAlpacaProtocol(out BadRequestObjectResult Result)
3737 Logging . Log . LogError ( $ "Error on request { HttpContext . Request . Path } with details: { Result . Value ? . ToString ( ) } ") ;
3838 return true ;
3939 }
40+
41+
42+ if ( HttpContext . Request . Query . Any ( ) )
43+ {
44+ var keys = HttpContext . Request . Query . Keys ;
45+ Result = BadRequest ( Strings . FormWithQueryDescription + string . Join ( ", " , keys ) ) ;
46+ Logging . Log . LogError ( $ "Error on request { HttpContext . Request . Path } with details: { Result . Value ? . ToString ( ) } ") ;
47+ return true ;
48+ }
4049 }
4150
4251 if ( HttpContext . Request . Query . Keys . Any ( key => ! ValidAlpacaKeys . ValidParameterKeys . Contains ( key ) ) )
4352 {
4453 var keys = HttpContext . Request . Query . Keys . Where ( key => ! ValidAlpacaKeys . ValidParameterKeys . Contains ( key ) ) ;
45- Result = BadRequest ( Strings . QueryCapitalizationDescription + string . Join ( ", " , keys ) ) ;
54+ Result = BadRequest ( Strings . FormCapitalizationDescription + string . Join ( ", " , keys ) ) ;
55+ Logging . Log . LogError ( $ "Error on request { HttpContext . Request . Path } with details: { Result . Value ? . ToString ( ) } ") ;
56+ return true ;
57+ }
58+
59+ if ( HttpContext . Request . Method == "GET" && HttpContext . Request . HasFormContentType && HttpContext . Request . Form . Keys . Any ( ) )
60+ {
61+ var keys = HttpContext . Request . Form . Keys ;
62+ Result = BadRequest ( Strings . QueryWithFormDescription + string . Join ( ", " , keys ) ) ;
4663 Logging . Log . LogError ( $ "Error on request { HttpContext . Request . Path } with details: { Result . Value ? . ToString ( ) } ") ;
4764 return true ;
4865 }
Original file line number Diff line number Diff line change @@ -10,5 +10,7 @@ public class Strings
1010 public const string URLCapitalizationDescription = @"The API URL is required to be lowercase. Supplied URL: " ;
1111 public const string FormCapitalizationDescription = @"The API Form is required to match the Alpaca Specification. Unknown Form Key(s): " ;
1212 public const string QueryCapitalizationDescription = @"The API Query is required to match the Alpaca Specification. Unknown Query Key(s): " ;
13+ public const string FormWithQueryDescription = @"A Form request should not have any Query Keys. Unknown Query Key(s): " ;
14+ public const string QueryWithFormDescription = @"A Query request should not have any Form Keys. Unknown Form Key(s): " ;
1315 }
1416}
You can’t perform that action at this time.
0 commit comments