Software /
code /
prosody
Comparison
net/http.lua @ 4356:10a4f3b081a7
net.http: Convert port to a number (for custom port in URL)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 22 Aug 2011 12:57:52 -0400 |
parent | 4355:9e2a841739b5 |
child | 4369:3578ff5d3674 |
comparison
equal
deleted
inserted
replaced
4355:9e2a841739b5 | 4356:10a4f3b081a7 |
---|---|
132 | 132 |
133 -- Attach to request object | 133 -- Attach to request object |
134 req.method, req.headers, req.body = method, headers, body; | 134 req.method, req.headers, req.body = method, headers, body; |
135 | 135 |
136 local using_https = req.scheme == "https"; | 136 local using_https = req.scheme == "https"; |
137 local port = req.port or (using_https and 443 or 80); | 137 local port = tonumber(req.port) or (using_https and 443 or 80); |
138 | 138 |
139 -- Connect the socket, and wrap it with net.server | 139 -- Connect the socket, and wrap it with net.server |
140 local conn = socket.tcp(); | 140 local conn = socket.tcp(); |
141 conn:settimeout(10); | 141 conn:settimeout(10); |
142 local ok, err = conn:connect(req.host, port); | 142 local ok, err = conn:connect(req.host, port); |