Skip to content

Commit

Permalink
Move FileResponse to HttpServer.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
IainNZ committed Sep 6, 2015
1 parent c65f1a8 commit b6821d8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1,000 deletions.
18 changes: 1 addition & 17 deletions src/HttpCommon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ module HttpCommon
import URIParser: URI, unescape

export Headers, Request, Cookie, Response,
escapeHTML, parsequerystring,
FileResponse
escapeHTML, parsequerystring

export mimetypes
include("mimetypes.jl")

# All HTTP status codes, as a Dict of code => description
export STATUS_CODES
Expand Down Expand Up @@ -105,19 +102,6 @@ Base.show(io::IO, r::Response) = print(io, "Response(",
sizeof(r.data)," bytes in body)")



function FileResponse(filename)
if isfile(filename)
s = open(readbytes,filename)
(_, ext) = splitext(filename)
mime = length(ext)>1 && haskey(mimetypes,ext[2:end]) ? mimetypes[ext[2:end]] : "application/octet-stream"
Response(200, Dict{String,String}([("Content-Type",mime)]), s)
else
Response(404, "Not Found - file $filename could not be found")
end
end


"""
escapeHTML(i::String)
Expand Down
Loading

0 comments on commit b6821d8

Please sign in to comment.