Skip to content
Snippets Groups Projects
Verified Commit 88f2e482 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

modules/http: test connection to an AF_UNIX socket

parent 38e37d9f
Branches
Tags
1 merge request!811daemon: support AF_UNIX sockets in the http module
Pipeline #48949 failed with stages
in 34 minutes and 53 seconds
......@@ -94,10 +94,29 @@ else
same(code, 400, '/trace requires name')
end
-- AF_UNIX tests (very basic ATM)
local function test_unix_socket()
local s_path = os.tmpname()
os.remove(s_path) -- on POSIX .tmpname() (usually) creates a file :-/
ok(net.listen(s_path, nil, { kind = 'webmgmt' }), 'AF_UNIX net.listen() on ' .. s_path)
-- Unfortunately we can't use standard functions for fetching http://
local socket = require("cqueues.socket")
local sock = socket.connect({ path = s_path })
local connection = require('http.h2_connection')
local conn = connection.new(sock, 'client')
local _, err = conn:connect()
os.remove(s_path) -- don't leave garbage around, hopefully not even on errors
same(err, nil, 'AF_UNIX connect(): ' .. (err or 'OK'))
same(conn:ping(), true, 'AF_UNIX http ping')
-- here we might do `conn:new_stream()` and some real queries
same(conn:close(), true, 'AF_UNIX close')
end
-- plan tests
local tests = {
start_server,
test_builtin_pages,
test_unix_socket,
}
return tests
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment