Skip to content

Commit

Permalink
Use the correct header name and add support in downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaliumhexacyanoferrat committed Dec 12, 2024
1 parent 17870dd commit edc050b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Modules/IO/Providers/DownloadProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public DownloadProvider(IResource resourceProvider, string? fileName, FlexibleCo

if (!request.HasType(RequestMethod.Get, RequestMethod.Head))
{
throw new ProviderException(ResponseStatus.MethodNotAllowed, "Only GET requests are allowed by this handler");
throw new ProviderException(ResponseStatus.MethodNotAllowed, "Only GET requests are allowed by this handler", (b) => b.Header("Allow", "GET, HEAD"));
}

var response = request.Respond()
Expand Down
6 changes: 3 additions & 3 deletions Modules/Reflection/MethodCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public MethodCollection(IEnumerable<MethodHandler> methods)

if (others.Count > 0)
{
throw new ProviderException(ResponseStatus.MethodNotAllowed, "There is no method of a matching request type", AddAcceptHeader);
throw new ProviderException(ResponseStatus.MethodNotAllowed, "There is no method of a matching request type", AddAllowHeader);

void AddAcceptHeader(IResponseBuilder b)
void AddAllowHeader(IResponseBuilder b)
{
b.Header("Accept", string.Join(", ", others.Select(o => o.RawMethod.ToUpper())));
b.Header("Allow", string.Join(", ", others.Select(o => o.RawMethod.ToUpper())));
}
}

Expand Down

0 comments on commit edc050b

Please sign in to comment.