Skip to content

Commit

Permalink
Fix test cases for Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Feb 23, 2024
1 parent a8ef828 commit 932ab4a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions tests/vibe.http.client.1389/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ shared static this()
auto url = "http://"~serverAddr.toString;
logInfo(url);

auto cs = new HTTPClientSettings;
cs.networkInterface = resolveHost("127.0.0.1");
auto res = requestHTTP(url, null, cs).bodyReader.readAllUTF8();
assert(res == "local", "Unexpected reply: "~res);
string res;

version (Windows) {}
else {
auto cs = new HTTPClientSettings;
cs.networkInterface = resolveHost("127.0.0.1");
res = requestHTTP(url, null, cs).bodyReader.readAllUTF8();
assert(res == "local", "Unexpected reply: "~res);
}

auto cs2 = new HTTPClientSettings;
cs2.networkInterface = resolveHost(externalAddr.toAddressString());
Expand Down
7 changes: 5 additions & 2 deletions tests/vibe.http.client.1426/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ extern(C) __gshared string[] rt_options = [ "gcopt=parallel:0" ];
int main ()
{
immutable serverAddr = listenTCP(0, (TCPConnection c) @safe nothrow {
try c.write("HTTP/1.1 200 OK\r\nConnection: Close\r\n\r\nqwerty");
catch (Exception e) assert(0, e.msg);
try {
// skip request
c.readUntil(cast(immutable(ubyte)[])"\r\n\r\n");
c.write("HTTP/1.1 200 OK\r\nConnection: Close\r\n\r\nqwerty");
} catch (Exception e) assert(0, e.msg);
}, "127.0.0.1").bindAddress;

runTask({
Expand Down
6 changes: 4 additions & 2 deletions tests/vibe.http.server.listenHTTP/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import std.socket : AddressFamily;

shared static this()
{
immutable serverAddr = listenHTTP(":0", (scope req, scope res) {
immutable serverPort = listenHTTP(":0", (scope req, scope res) {
res.writeBody("Hello world.");
}).bindAddresses.find!(addr => addr.family == AddressFamily.INET).front;
}).bindAddresses.find!(addr => addr.family == AddressFamily.INET).front.port;
auto serverAddr = resolveHost("127.0.0.1");
serverAddr.port = serverPort;

runTask({
scope (exit) exitEventLoop();
Expand Down

0 comments on commit 932ab4a

Please sign in to comment.