Support for arbitrary HTTP methods #1

Closed
opened 2024-10-27 15:24:48 +00:00 by 0xEAB · 2 comments

Currently, HTTP request methods are limited to a predefined number of verbs from the HttpMethod enum.

This has two problems:

  • https://www.php-fig.org/psr/psr-7/

    While HTTP method names are typically all uppercase characters, HTTP
    method names are case-sensitive and thus implementations SHOULD NOT
    modify the given string.

  • It makes the library unusable for protocols that build upon HTTP but add their own verbs on top, e.g. WebDAV.

IMHO, the HTTP request method should be stored as a string.

Currently, HTTP request methods are limited to a predefined number of verbs from the [HttpMethod](https://git.andrewlalis.com/Handy-Http/primitives/src/commit/23c74f82bedf662d3d6f8f2aed159a270f5a782d/source/handy_http_primitives/request.d#L44) enum. This has two problems: - <https://www.php-fig.org/psr/psr-7/> > While HTTP method names are typically all uppercase characters, HTTP > method names are case-sensitive and thus implementations SHOULD NOT > modify the given string. - It makes the library unusable for protocols that build upon HTTP but add their own verbs on top, e.g. [WebDAV](https://datatracker.ietf.org/doc/html/rfc4918#page-35). IMHO, the HTTP request method should be stored as a string.
Author

The HttpStatus enum, on the other hand, already contains WebDAV status codes, like
https://git.andrewlalis.com/Handy-Http/primitives/src/commit/23c74f82bedf662d3d6f8f2aed159a270f5a782d/source/handy_http_primitives/response.d#L81-L83
and AFAICT can be used in a way to allow arbitrary response codes as-is, thus doesn’t have this issue.

The `HttpStatus` enum, on the other hand, already contains WebDAV status codes, like <https://git.andrewlalis.com/Handy-Http/primitives/src/commit/23c74f82bedf662d3d6f8f2aed159a270f5a782d/source/handy_http_primitives/response.d#L81-L83> and AFAICT can be used in a way to allow arbitrary response codes as-is, thus doesn’t have this issue.
Owner

Yep, you're right; I'm changing the type to const string method;. But I will still provide enum HttpMethod : string as a convenience for common methods.

Yep, you're right; I'm changing the type to `const string method;`. But I will still provide `enum HttpMethod : string` as a convenience for common methods.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Handy-Http/primitives#1
No description provided.