@@ -21,7 +21,7 @@ public static class SqlStreamStoreHalMiddleware
2121
2222 context . Response . OnSendingHeaders ( _ =>
2323 {
24- context . Response . Headers [ "Access-Control-Allow-Methods" ] = "GET, OPTIONS" ;
24+ context . Response . Headers [ "Access-Control-Allow-Methods" ] = "GET, HEAD, OPTIONS" ;
2525 context . Response . Headers [ "Access-Control-Allow-Headers" ]
2626 = "Content-Type, X-Requested-With, Authorization" ;
2727 context . Response . Headers [ "Access-Control-Allow-Origin" ] = "*" ;
@@ -31,6 +31,24 @@ public static class SqlStreamStoreHalMiddleware
3131 return next ( env ) ;
3232 } ;
3333
34+ private static MidFunc AddReasonPhrase => next => env =>
35+ {
36+ var context = new OwinContext ( env ) ;
37+
38+ context . Response . OnSendingHeaders ( _ =>
39+ {
40+ if ( ! Constants . ReasonPhrases . TryGetValue ( context . Response . StatusCode , out var reasonPhrase ) )
41+ {
42+ return ;
43+ }
44+
45+ context . Response . ReasonPhrase = reasonPhrase ;
46+ } ,
47+ null ) ;
48+
49+ return next ( env ) ;
50+ } ;
51+
3452 private static MidFunc Index => next => env =>
3553 {
3654 var context = new OwinContext ( env ) ;
@@ -52,6 +70,7 @@ public static MidFunc UseSqlStreamStoreHal(IStreamStore streamStore)
5270
5371 var builder = new AppBuilder ( )
5472 . Use ( AccessControl )
73+ . Use ( AddReasonPhrase )
5574 . Use ( Index )
5675 . Map ( "/stream" , inner => inner
5776 . Use ( ReadAllStreamMiddleware . UseStreamStore ( streamStore ) )
@@ -81,7 +100,6 @@ private static MidFunc MethodsNotAllowed(params string[] methods)
81100 }
82101
83102 context . Response . StatusCode = 405 ;
84- context . Response . ReasonPhrase = "Method Not Allowed" ;
85103
86104 return Task . CompletedTask ;
87105 } ;
0 commit comments