Skip to content

support less-commonly-used HTTP verbs: PUT, PATCH, DELETE#79

Open
cuchaz wants to merge 1 commit intoferronweb:developfrom
cuchaz:less-common-verbs
Open

support less-commonly-used HTTP verbs: PUT, PATCH, DELETE#79
cuchaz wants to merge 1 commit intoferronweb:developfrom
cuchaz:less-common-verbs

Conversation

@cuchaz
Copy link
Contributor

@cuchaz cuchaz commented May 26, 2025

Looks like Ruby-on-Rails apps heavily use less-commonly-used HTTP verbs, so this patch adds support for them.

I'm not entirely sure if this is the right way to patch in support for new HTTP verbs in general, but it did work on my server. Let me know what you think. In my case, I only need the extra verbs for a reverse proxied host, and I think this patch is more general than that?

since it seems they're used by Ruby-on-Rails apps
Response::builder()
.status(StatusCode::NO_CONTENT)
.header(header::ALLOW, "GET, POST, HEAD, OPTIONS")
.header(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code - Priority: High
This block of code is duplicated in ferron/src/request_handler.rs starting at line 805.

_ => {
let mut header_map = HeaderMap::new();
if let Ok(header_value) = HeaderValue::from_str("GET, POST, HEAD, OPTIONS") {
if let Ok(header_value) =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code - Priority: High
This block of code is duplicated in ferron/src/request_handler.rs starting at line 813.

@hikaflow
Copy link

hikaflow bot commented May 26, 2025

PR Summary

Changes Overview

  • No changes were identified in the provided file summaries.

Identified Issues

  • No issues found.

Recommendations

  • None at this time.

@DorianNiemiecSVRJS DorianNiemiecSVRJS added the rust Pull requests that update rust code label May 26, 2025
@DorianNiemiecSVRJS
Copy link
Member

I was thinking about security scanners...
When I compiled your patched version, and run a nikto scan against it, this appeared:

+ Allowed HTTP Methods: GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE 
+ OSVDB-397: HTTP method ('Allow' Header): 'PUT' method could allow clients to save files on the web server.
+ OSVDB-5646: HTTP method ('Allow' Header): 'DELETE' may allow clients to remove files on the web server.

@cuchaz
Copy link
Contributor Author

cuchaz commented May 26, 2025

Yeah, depending on what host is receiving the verbs, that could indeeed be a security concern. So maybe less-common verb support needs to be configured per-host?

@DorianNiemiecSVRJS
Copy link
Member

Yes, I think that's a good idea to introduce a configuration option for allowing "PUT", "PATCH", and "DELETE" HTTP methods.

@hongquan
Copy link
Contributor

hongquan commented Jan 2, 2026

OSVDB-397: HTTP method ('Allow' Header): 'PUT' method could allow clients to save files on the web server.

Why have to concern about PUT, because POST already allows clients to save files on the web server and we already allow POST?
The same apply for PATCH and DELETE. These three verbs are quite common for RESTful API and they have been used for a long time.

@DorianNiemiecSVRJS
Copy link
Member

I have marked Ferron 1.x as "in maintenance mode" in the f3de200 commit, so I'm not sure if I'm going to merge your pull request, as it's against the development branch for Ferron 1.x...

You can open a pull request against develop-2.x branch (for Ferron 2) instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants