test: fix on BSD (where bind to 127.0.0.0 doesn't work)
This commit is contained in:
parent
c2043fd971
commit
34f15103fa
1 changed files with 9 additions and 7 deletions
16
test/test.ml
16
test/test.ml
|
@ -113,14 +113,16 @@ let server ?error ?stop stack = function
|
||||||
let alpn_service = HTTP_server.alpn_service ~tls alpn_handler in
|
let alpn_service = HTTP_server.alpn_service ~tls alpn_handler in
|
||||||
HTTP_server.serve ?stop alpn_service http_server
|
HTTP_server.serve ?stop alpn_service http_server
|
||||||
|
|
||||||
let stack ipaddr =
|
let stack () =
|
||||||
let open Lwt.Syntax in
|
let open Lwt.Syntax in
|
||||||
|
let ip = Ipaddr.V4.(Prefix.make 8 localhost) in
|
||||||
|
let ipv4_only = true and ipv6_only = false in
|
||||||
let* tcpv4v6 =
|
let* tcpv4v6 =
|
||||||
Tcpip_stack_socket.V4V6.TCP.connect ~ipv4_only:false ~ipv6_only:false ipaddr
|
Tcpip_stack_socket.V4V6.TCP.connect ~ipv4_only ~ipv6_only ip None
|
||||||
None in
|
in
|
||||||
let* udpv4v6 =
|
let* udpv4v6 =
|
||||||
Tcpip_stack_socket.V4V6.UDP.connect ~ipv4_only:false ~ipv6_only:false ipaddr
|
Tcpip_stack_socket.V4V6.UDP.connect ~ipv4_only ~ipv6_only ip None
|
||||||
None in
|
in
|
||||||
Tcpip_stack_socket.V4V6.connect udpv4v6 tcpv4v6
|
Tcpip_stack_socket.V4V6.connect udpv4v6 tcpv4v6
|
||||||
|
|
||||||
let test01 =
|
let test01 =
|
||||||
|
@ -139,7 +141,7 @@ let test01 =
|
||||||
] in
|
] in
|
||||||
let response = Response.create ~headers `OK in
|
let response = Response.create ~headers `OK in
|
||||||
Reqd.respond_with_string reqd response contents in
|
Reqd.respond_with_string reqd response contents in
|
||||||
let* stack = stack Ipaddr.V4.Prefix.loopback in
|
let* stack = stack () in
|
||||||
let happy_eyeballs = Happy_eyeballs.create stack in
|
let happy_eyeballs = Happy_eyeballs.create stack in
|
||||||
let* ctx = Mimic_happy_eyeballs.connect happy_eyeballs in
|
let* ctx = Mimic_happy_eyeballs.connect happy_eyeballs in
|
||||||
let* t = HTTP_client.connect ctx in
|
let* t = HTTP_client.connect ctx in
|
||||||
|
@ -186,7 +188,7 @@ let test02 =
|
||||||
Body.write_bigstring dst ~off ~len buf
|
Body.write_bigstring dst ~off ~len buf
|
||||||
; Body.schedule_read src ~on_eof ~on_read in
|
; Body.schedule_read src ~on_eof ~on_read in
|
||||||
Body.schedule_read src ~on_eof ~on_read in
|
Body.schedule_read src ~on_eof ~on_read in
|
||||||
let* stack = stack Ipaddr.V4.Prefix.loopback in
|
let* stack = stack () in
|
||||||
let happy_eyeballs = Happy_eyeballs.create stack in
|
let happy_eyeballs = Happy_eyeballs.create stack in
|
||||||
let* ctx = Mimic_happy_eyeballs.connect happy_eyeballs in
|
let* ctx = Mimic_happy_eyeballs.connect happy_eyeballs in
|
||||||
let* t = HTTP_client.connect ctx in
|
let* t = HTTP_client.connect ctx in
|
||||||
|
|
Loading…
Reference in a new issue