-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for 'QUERY' method #51562
Comments
@nodejs/http |
This is technically doable, but it will involve a PR in llhttp (the current Node.js HTTP parser) first and then it will be automatically supported by Node. |
cc @jasnell (http QUERY is your spec right?) |
Yes! Interested in doing this. Will give this a shot |
llhttp supports QUERY with nodejs/llhttp#265, so when released it will be possible to implement this on node |
Cool, thanks for doing that! |
When this PR #51719 is merged should be possible to support it |
Hey folks, Im not seeing QUERY support in Node post #51719 landing Should this have gone out in Guessing that it might need additional work in node? Expected support because I'm using this as a test and tracking adding support in express in expressjs/express#5615: // filename: http.js
const http = require('http');
// Do we know about query?
console.log(http.METHODS.includes('QUERY')) // true
// Create an HTTP server
const server = http.createServer((req, res) => {
// Log the method to the console for verification
console.log('Received method:', req.method);
// Check if the method is QUERY
if (req.method === 'QUERY') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Received a QUERY method request');
} else {
// Respond with Method Not Allowed if the method is not QUERY
res.writeHead(405, { 'Content-Type': 'text/plain' });
res.end('Method Not Allowed');
}
});
// Listen on port 3000
server.listen(3000, () => {
console.log('Server listening on port 3000');
}); node -v
# v21.7.3
node http.js
curl -i -X QUERY -H "Content-Type: application/json" -d '{"foo": "bar"}' http://localhost:3000 I see for completeness:
And I am reproing locally on mac os, but also in GHA |
@ShogunPanda triaged the issue, and if Im not mistaken its a trivial bug on Node side |
Does anyone know where we should look in code to add a path to support the QUERY method? |
It should he already supported, there is just a little bug so its not listen in METHODS |
Seems like I found the location, it's missing from |
I'm just not sure if it's the only place where we should be looking for, or is it? |
@ShogunPanda may know more about it |
Yes, I just submitted #52701. To address this. |
This serves two purposes: - Enforcing constraints on its actual usage in `walkRouting()`, - Should ease adoption of the new `QUERY` method in the future, see: - expressjs/express#5615 - nodejs/node#51562
This serves two purposes: - Enforcing constraints on its actual usage in `walkRouting()`, - Should ease adoption of the new `QUERY` method in the future, see: - expressjs/express#5615 - nodejs/node#51562
This serves two purposes: - Enforcing constraints on its actual usage in `walkRouting()`, - Should ease adoption of the new `QUERY` method in the future, see: - expressjs/express#5615 - nodejs/node#51562
Any chance #52701 will be backported to 21? QUERY is still failing there, but reported in |
Thank you! |
v21 is EOL and v20 has an old major version of llhttp so I think it's unlikely |
Unless |
I dont think it will be backported to v20 for the reason stated in my previous comment also v20 going into maintenance mode next month. Closing as resolved |
Version
v20.10.0
Platform
Linux evertbook6f 6.6.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jan 10 19:25:59 UTC 2024 x86_64 GNU/Linux
Subsystem
node:http
What steps will reproduce the bug?
The
QUERY
http method has a fair bit of interest and will likely at some point get standardized. There's a draft here:https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-02.html
Currently (as far as I'm aware) it's not possible to define custom methods in the Node
http
package, preventing users from testing with this. Although I understand this was probably done for parser performance reasons, HTTP does have an explicit extension mechanism for new methods and recommendations on how to treat unknown ones, so I do feel it goes a bit counter against the spirit of HTTP to not allow new methods. Browsers will for example let users use any (unregistered) http method infetch()
.That said, I understand that supporting any unknown HTTP method is probably a lot of work, so I'll settle for having support for the
QUERY
http method!How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
Currently Node returns a
400 Bad Request
Additional information
No response
The text was updated successfully, but these errors were encountered: