Skip to content

Commit 41f1771

Browse files
committed
fix format not found
1 parent 0207d5c commit 41f1771

2 files changed

Lines changed: 2 additions & 12 deletions

File tree

src/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function handler(request::HTTP.Messages.Request)
4343

4444
if ((request.method=="POST" )||(request.method=="PUT" )||(request.method=="PATCH"))
4545
header_content_type = HTTP.header(request, "Content-Type")
46-
if(length(header_content_type)>0)
46+
if((length(header_content_type)>0) && (haskey(formats,header_content_type)))
4747
my_request.body= getindex(formats, header_content_type)(String(request.body))
4848
else
4949
my_request.body = getindex(formats, "*/*")(String(request.body))

test/runtests.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ r = HTTP.get("http://$(ip):$(port)/data?hola=1")
9494
@test String(r.body) == "hellodata"
9595

9696
myjson = Dict("query"=>"data")
97-
my_headers = HTTP.mkheaders(["Accept" => "application/json","Content-Type" => "application/json"])
97+
my_headers = HTTP.mkheaders(["Accept" => "application/json","Content-Type" => "application/xml"])
9898
r = HTTP.post("http://$(ip):$(port)/data",my_headers,JSON.json(myjson))
9999
@test r.status == 200
100100
@test String(r.body) == "I did something!"
@@ -138,16 +138,6 @@ r = HTTP.get("http://$(ip):$(port)/prueba.txt")
138138
@test String(r.body) == "probando webserver"
139139
@test r.headers == Pair{SubString{String},SubString{String}}["Content-Type"=>"text/plain", "Access-Control-Allow-Origin"=>"*", "Access-Control-Allow-Methods"=>"POST,GET,OPTIONS", "Strict-Transport-Security"=>"max-age=10886400; includeSubDomains; preload", "Transfer-Encoding"=>"chunked"]
140140

141-
r = HTTP.get("http://$(ip):$(port)/Index.html")
142-
@test r.status == 200
143-
if Sys.iswindows()
144-
@test String(r.body) == "<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n\t<meta charset=\"UTF-8\">\r\n\t<title>Document</title>\r\n</head>\r\n<body>\r\n<h1>hola</h1>\r\n</body>\r\n</html>"
145-
else
146-
@test String(r.body) == "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>Document</title>\n</head>\n<body>\n<h1>hola</h1>\n</body>\n</html>"
147-
end
148-
@test r.headers == Pair{SubString{String},SubString{String}}["Content-Type"=>"text/html", "Access-Control-Allow-Origin"=>"*", "Access-Control-Allow-Methods"=>"POST,GET,OPTIONS", "Strict-Transport-Security"=>"max-age=10886400; includeSubDomains; preload", "Transfer-Encoding"=>"chunked"]
149-
150-
151141
r= HTTP.get("http://$(ip):$(port)/regex/test1")
152142
@test String(r.body) == "datos test1"
153143

0 commit comments

Comments
 (0)