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
How would I implement a 400 bad request error handling in Bukdu?
Should I overwrite the Bukdu.System.internal_error method or is there a better way.
Thanks.
using Bukdu
using Test
using Sockets
port =8080
Bukdu.start(port)
# from https://github.com/JuliaWeb/HTTP.jl/blob/master/test/server.jl# invalid HTTP
tcp = Sockets.connect(ip"127.0.0.1", port)
write(tcp, "GET / HTP/1.1\r\n\r\n")
sleep(0.1)
@testoccursin(r"HTTP/1.1 400 Bad Request", String(readavailable(tcp)))
# no URL
tcp = Sockets.connect(ip"127.0.0.1", port)
write(tcp, "SOMEMETHOD HTTP/1.1\r\nContent-Length: 0\r\n\r\n")
sleep(0.1)
r =String(readavailable(tcp))
@testoccursin(r"HTTP/1.1 400 Bad Request", r)
Bukdu.stop()
I am not sure, but I think my case is not covered.
In my application, I receive a lot of huge JSONs via Post request. I would like to check the content of the request if it contains the correct keys and return a Bad Request Message if the keys does not exist.
Activity
wookay commentedon Jun 12, 2020
at first, see
HTTP.jl's implementation.do you have any other case?
ueliwechsler commentedon Jun 15, 2020
Thanks for your detailed response.
I am not sure, but I think my case is not covered.
In my application, I receive a lot of huge JSONs via Post request. I would like to check the content of the request if it contains the correct keys and return a
Bad RequestMessage if the keys does not exist.wookay commentedon Jun 15, 2020
then you could set the
response.status. make a function or plug.ueliwechsler commentedon Jun 18, 2020
Thank you, this works for me.