Mercurial Hosting > luan
changeset 1237:275d1b52dbce
add Request.scheme
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 11 Jun 2018 18:22:51 -0600 |
parents | 5b9856045e51 |
children | 3d29033de2bf |
files | src/luan/modules/http/Http.luan src/luan/webserver/Connection.java src/luan/webserver/Request.java src/luan/webserver/RequestParser.java |
diffstat | 4 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
diff -r 5b9856045e51 -r 275d1b52dbce src/luan/modules/http/Http.luan --- a/src/luan/modules/http/Http.luan Fri May 25 00:58:05 2018 -0600 +++ b/src/luan/modules/http/Http.luan Mon Jun 11 18:22:51 2018 -0600 @@ -30,6 +30,7 @@ Http.request = this if java == nil then this.method = "GET" + this.scheme = "http" this.headers = {} this.parameters = {} this.cookies = {} @@ -40,11 +41,11 @@ this.raw_path = java.rawPath or error() this.path = java.path or error() this.protocol = java.protocol or error() + this.scheme = java.scheme or error() this.headers = JavaLuan.toLuan(java.headers) this.parameters = JavaLuan.toLuan(java.parameters) this.cookies = JavaLuan.toLuan(java.cookies) end - this.scheme = "http" function this.url() return this.scheme.."://"..this.headers["host"]..this.raw_path
diff -r 5b9856045e51 -r 275d1b52dbce src/luan/webserver/Connection.java --- a/src/luan/webserver/Connection.java Fri May 25 00:58:05 2018 -0600 +++ b/src/luan/webserver/Connection.java Mon Jun 11 18:22:51 2018 -0600 @@ -92,6 +92,10 @@ logger.info("unknown request content-type: "+contentType); } } + + String scheme = (String)request.headers.get("x-forwarded-proto"); + if( scheme != null ) + request.scheme = scheme; } response = server.handler.handle(request); } catch(ParseException e) {
diff -r 5b9856045e51 -r 275d1b52dbce src/luan/webserver/Request.java --- a/src/luan/webserver/Request.java Fri May 25 00:58:05 2018 -0600 +++ b/src/luan/webserver/Request.java Mon Jun 11 18:22:51 2018 -0600 @@ -11,6 +11,7 @@ public volatile String rawPath; public volatile String path; public volatile String protocol; // only HTTP/1.1 is accepted + public volatile String scheme; public final Map<String,Object> headers = Collections.synchronizedMap(new LinkedHashMap<String,Object>()); public final Map<String,Object> parameters = Collections.synchronizedMap(new LinkedHashMap<String,Object>()); public final Map<String,String> cookies = Collections.synchronizedMap(new LinkedHashMap<String,String>());
diff -r 5b9856045e51 -r 275d1b52dbce src/luan/webserver/RequestParser.java --- a/src/luan/webserver/RequestParser.java Fri May 25 00:58:05 2018 -0600 +++ b/src/luan/webserver/RequestParser.java Mon Jun 11 18:22:51 2018 -0600 @@ -108,6 +108,7 @@ ) ) throw new ParseException(parser,"bad protocol"); request.protocol = parser.textFrom(start); + request.scheme = "http"; }