You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying your nice extractors, and I came about something surprising. Basic code:
export start1
using Oxygen
struct Form1
name::Stringendfunctionhdl_form1(req, data::Form{Form1})
display(data.payload)
endfunctionstart1()
@post"/form1" hdl_form1
serve()
end
Problem 1 (500 instead of 400)
Then, doing curl -X POST http://localhost:8080/form1 --data 'name=John' works fine (as expected).
But doing curl -X POST http://localhost:8080/form1 --data '' or curl -X POST http://localhost:8080/form1 --data 'toto=lala' responds with a 500: Internal Server Error, and the server prints an error.
These last requests are bad requests, and I suppose the server should treat them as such, appropriately return a 400: Bad Request to indicate to the client that the problem lies with him (malformed request, not a server problem), and not print errors (as these are not server errors). Or am I missing a way to properly handle this?
Problem 2 (extraneous data is ignored)
If you do curl -X POST http://localhost:8080/form1 --data 'name=Jean&x=3', the server accepts the data silently. While this behavior is sometimes desirable, it would be nice to be able to disable it and be able to also return a 400: Bad Request to the client in case of extraneous data. That would make debugging easier in many cases. Could there be a way to do it?
I would even argue it should be the default, but I guess that really depends on taste and goals.
The text was updated successfully, but these errors were encountered:
Hello,
I was trying your nice extractors, and I came about something surprising. Basic code:
Problem 1 (500 instead of 400)
Then, doing
curl -X POST http://localhost:8080/form1 --data 'name=John'
works fine (as expected).But doing
curl -X POST http://localhost:8080/form1 --data ''
orcurl -X POST http://localhost:8080/form1 --data 'toto=lala'
responds with a500: Internal Server Error
, and the server prints an error.These last requests are bad requests, and I suppose the server should treat them as such, appropriately return a
400: Bad Request
to indicate to the client that the problem lies with him (malformed request, not a server problem), and not print errors (as these are not server errors). Or am I missing a way to properly handle this?Problem 2 (extraneous data is ignored)
If you do
curl -X POST http://localhost:8080/form1 --data 'name=Jean&x=3'
, the server accepts the data silently. While this behavior is sometimes desirable, it would be nice to be able to disable it and be able to also return a400: Bad Request
to the client in case of extraneous data. That would make debugging easier in many cases. Could there be a way to do it?I would even argue it should be the default, but I guess that really depends on taste and goals.
The text was updated successfully, but these errors were encountered: