Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/Gren/Kernel/HttpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ var _HttpServer_addListener = F3(function (server, router, msg) {
.on("end", function () {
const buffer = Buffer.concat(body);
let grenRequest = __HttpServer_toRequest({
__$urlProtocol: url.protocol,
__$urlHost: url.hostname,
__$urlPort: url.port,
__$urlPath: url.pathname,
__$urlQuery: url.search,
__$urlFragment: url.hash,
__$url: url.href,
__$headers: request.rawHeaders,
__$method: request.method,
__$body: new DataView(
Expand Down
46 changes: 13 additions & 33 deletions src/HttpServer.gren
Original file line number Diff line number Diff line change
Expand Up @@ -162,54 +162,34 @@ methodToString method =
This is only used internally.
-}
toRequest :
{ urlProtocol : String
, urlHost : String
, urlPort : String
, urlPath : String
, urlQuery : String
, urlFragment : String
{ url : String
, headers : Array String
, method : String
, body : Bytes
}
-> Request
toRequest
{ urlProtocol
, urlHost
, urlPort
, urlPath
, urlQuery
, urlFragment
{ url
, headers
, method
, body
} =
{ method = toMethod method
, body = body
, url =
Url.fromString url
|> Maybe.withDefault
{ protocol = Http
, port_ = Nothing
, host = ""
, path = ""
, query = Nothing
, fragment = Nothing
}
, headers =
headers
|> arrayPairs
|> dictFromPairs
, url =
{ protocol =
if urlProtocol == "https:" then
Https
else
Http
, host = urlHost
, path = urlPath
, port_ = String.toInt urlPort
, query =
if urlQuery == "" then
Nothing
else
Just urlQuery
, fragment =
if urlFragment == "" then
Nothing
else
Just urlFragment
}
}


Expand Down Expand Up @@ -266,7 +246,7 @@ requestInfo req =
UNKNOWN m ->
"UNKNOWN(" ++ m ++ ")"
in
method ++ " " ++ req.url.path
method ++ " " ++ (Url.toString req.url)


toMethod : String -> Method
Expand Down
Loading