Software /
code /
prosody
Comparison
net/http.lua @ 11048:160308b4b384
net.http: use new net.http.errors lib for creating error object
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 25 Aug 2020 15:57:39 +0100 |
parent | 11017:1f41f38a92f7 |
child | 11049:f103f59ea2b5 |
comparison
equal
deleted
inserted
replaced
11047:93cdd1ece689 | 11048:160308b4b384 |
---|---|
11 local httpstream_new = require "net.http.parser".new; | 11 local httpstream_new = require "net.http.parser".new; |
12 local util_http = require "util.http"; | 12 local util_http = require "util.http"; |
13 local events = require "util.events"; | 13 local events = require "util.events"; |
14 local verify_identity = require"util.x509".verify_identity; | 14 local verify_identity = require"util.x509".verify_identity; |
15 local promise = require "util.promise"; | 15 local promise = require "util.promise"; |
16 local errors = require "util.error"; | 16 local http_errors = require "net.http.errors"; |
17 | 17 |
18 local basic_resolver = require "net.resolvers.basic"; | 18 local basic_resolver = require "net.resolvers.basic"; |
19 local connect = require "net.connect".connect; | 19 local connect = require "net.connect".connect; |
20 | 20 |
21 local ssl_available = pcall(require, "ssl"); | 21 local ssl_available = pcall(require, "ssl"); |
289 return request(self, u, ex, callback); | 289 return request(self, u, ex, callback); |
290 else | 290 else |
291 return promise.new(function (resolve, reject) | 291 return promise.new(function (resolve, reject) |
292 request(self, u, ex, function (body, code, a, b) | 292 request(self, u, ex, function (body, code, a, b) |
293 if code == 0 then | 293 if code == 0 then |
294 reject(errors.new(body, { request = a })); | 294 reject(http_errors.new(body, { request = a })); |
295 else | 295 else |
296 resolve({ request = b, response = a }); | 296 resolve({ request = b, response = a }); |
297 end | 297 end |
298 end); | 298 end); |
299 end); | 299 end); |