Mercurial > prosody-hg
comparison net/http.lua @ 8197:55826e29c719
net.http: Move default SSL/TLS settings into options, allowing them to be overriden in new()
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 07 Jul 2017 20:31:52 +0200 |
| parents | bc2bcfa63b43 |
| children | 8f82d3cd0631 |
comparison
equal
deleted
inserted
replaced
| 8196:bc2bcfa63b43 | 8197:55826e29c719 |
|---|---|
| 194 end | 194 end |
| 195 local port_number = port and tonumber(port) or (using_https and 443 or 80); | 195 local port_number = port and tonumber(port) or (using_https and 443 or 80); |
| 196 | 196 |
| 197 local sslctx = false; | 197 local sslctx = false; |
| 198 if using_https then | 198 if using_https then |
| 199 sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23", options = { "no_sslv2", "no_sslv3" } }; | 199 sslctx = ex and ex.sslctx or self.options and self.options.sslctx; |
| 200 end | 200 end |
| 201 | 201 |
| 202 local handler, conn = server.addclient(host, port_number, listener, "*a", sslctx) | 202 local handler, conn = server.addclient(host, port_number, listener, "*a", sslctx) |
| 203 if not handler then | 203 if not handler then |
| 204 self.events.fire_event("request-connection-error", { http = self, request = req, url = u, err = conn }); | 204 self.events.fire_event("request-connection-error", { http = self, request = req, url = u, err = conn }); |
| 237 events = events.new(); | 237 events = events.new(); |
| 238 }; | 238 }; |
| 239 return http; | 239 return http; |
| 240 end | 240 end |
| 241 | 241 |
| 242 local default_http = new(); | 242 local default_http = new({ |
| 243 sslctx = { mode = "client", protocol = "sslv23", options = { "no_sslv2", "no_sslv3" } }; | |
| 244 }); | |
| 243 | 245 |
| 244 return { | 246 return { |
| 245 request = function (u, ex, callback) | 247 request = function (u, ex, callback) |
| 246 return default_http:request(u, ex, callback); | 248 return default_http:request(u, ex, callback); |
| 247 end; | 249 end; |
