Mercurial Hosting > luan
changeset 1162:e2d2354807f3
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 06 Feb 2018 21:25:55 -0700 |
parents | 6baccd0c85a7 |
children | fef8f0742da9 |
files | src/luan/modules/http/Implementation.luan src/luan/modules/http/impl/Http.luan src/luan/modules/http/impl/Server.luan src/luan/webserver/Connection.java src/luan/webserver/Request.java |
diffstat | 5 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
diff -r 6baccd0c85a7 -r e2d2354807f3 src/luan/modules/http/Implementation.luan --- a/src/luan/modules/http/Implementation.luan Mon Feb 05 22:59:52 2018 -0700 +++ b/src/luan/modules/http/Implementation.luan Tue Feb 06 21:25:55 2018 -0700 @@ -1,4 +1,4 @@ return { - luan = "luan:http/jetty/" --- luan = "luan:http/impl/" +-- luan = "luan:http/jetty/" + luan = "luan:http/impl/" }
diff -r 6baccd0c85a7 -r e2d2354807f3 src/luan/modules/http/impl/Http.luan --- a/src/luan/modules/http/impl/Http.luan Mon Feb 05 22:59:52 2018 -0700 +++ b/src/luan/modules/http/impl/Http.luan Tue Feb 06 21:25:55 2018 -0700 @@ -25,14 +25,12 @@ local this = {} Http.request = this if java == nil then - this.port = 80 this.method = "GET" this.headers = {} this.parameters = {} this.cookies = {} else this.java = java - this.port = java.port or error() this.method = java.method or error() this.raw_path = java.rawPath or error() this.path = java.path or error()
diff -r 6baccd0c85a7 -r e2d2354807f3 src/luan/modules/http/impl/Server.luan --- a/src/luan/modules/http/impl/Server.luan Mon Feb 05 22:59:52 2018 -0700 +++ b/src/luan/modules/http/impl/Server.luan Tue Feb 06 21:25:55 2018 -0700 @@ -2,6 +2,7 @@ local error = Luan.error local String = require "luan:String.luan" local gsub = String.gsub or error() +local match = String.match or error() local matches = String.matches or error() local Io = require "luan:Io.luan" local Package = require "luan:Package.luan" @@ -29,14 +30,20 @@ Server.port = 8080 function Server.init(dir) - matches(dir,"^file:") or error "server dir must be scheme 'file:'" - dir = gsub(dir,"/$","") -- remove trailing '/' if any --- Http.dir = dir + local dir_uri, dir_path + if matches(dir,":") then + dir_uri = dir + dir_path = match(dir,"^file:(.*)$") or error "server dir must be scheme 'file:'" + else + dir_path = dir + dir_uri = "file:"..dir + end + dir_uri = gsub(dir_uri,"/$","") -- remove trailing '/' if any +-- Http.dir = dir_uri function Io.schemes.site(path) - return Io.uri( dir..path ) + return Io.uri( dir_uri..path ) end - local file_dir = Io.uri(dir).to_string() - local handler = FileHandler.new(file_dir) + local handler = FileHandler.new(dir_path) local luan_handler = LuanHandler.new() handler = ListHandler.new( luan_handler, handler ) handler = IndexHandler.new(handler)
diff -r 6baccd0c85a7 -r e2d2354807f3 src/luan/webserver/Connection.java --- a/src/luan/webserver/Connection.java Mon Feb 05 22:59:52 2018 -0700 +++ b/src/luan/webserver/Connection.java Tue Feb 06 21:25:55 2018 -0700 @@ -27,7 +27,6 @@ private void handle() { try { Request request = new Request(); - request.port = server.port; { InputStream in = socket.getInputStream(); byte[] a = new byte[8192];
diff -r 6baccd0c85a7 -r e2d2354807f3 src/luan/webserver/Request.java --- a/src/luan/webserver/Request.java Mon Feb 05 22:59:52 2018 -0700 +++ b/src/luan/webserver/Request.java Tue Feb 06 21:25:55 2018 -0700 @@ -6,7 +6,6 @@ public class Request { - public volatile int port; public volatile String rawHead; public volatile String method; public volatile String rawPath;