Skip to content

Commit 8a005bc

Browse files
authored
Merge pull request #808 from lightpanda-io/accept-header
http: send an Accept: */* header
2 parents a00c234 + 20aabee commit 8a005bc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/http/client.zig

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ pub const Request = struct {
732732
}
733733

734734
try self.headers.append(arena, .{ .name = "User-Agent", .value = "Lightpanda/1.0" });
735+
try self.headers.append(arena, .{ .name = "Accept", .value = "*/*" });
735736
self.requestStarting();
736737
}
737738

@@ -2863,11 +2864,12 @@ test "HttpClient: sync with body" {
28632864
}
28642865
try testing.expectEqual("over 9000!", try res.next());
28652866
try testing.expectEqual(201, res.header.status);
2866-
try testing.expectEqual(4, res.header.count());
2867+
try testing.expectEqual(5, res.header.count());
28672868
try testing.expectEqual("Close", res.header.get("connection"));
28682869
try testing.expectEqual("10", res.header.get("content-length"));
28692870
try testing.expectEqual("127.0.0.1", res.header.get("_host"));
28702871
try testing.expectEqual("Lightpanda/1.0", res.header.get("_user-agent"));
2872+
try testing.expectEqual("*/*", res.header.get("_accept"));
28712873
}
28722874
}
28732875

@@ -2939,11 +2941,12 @@ test "HttpClient: sync redirect from TLS to Plaintext" {
29392941
}
29402942
try testing.expectEqual(201, res.header.status);
29412943
try testing.expectEqual("over 9000!", arr.items);
2942-
try testing.expectEqual(4, res.header.count());
2944+
try testing.expectEqual(5, res.header.count());
29432945
try testing.expectEqual("Close", res.header.get("connection"));
29442946
try testing.expectEqual("10", res.header.get("content-length"));
29452947
try testing.expectEqual("127.0.0.1", res.header.get("_host"));
29462948
try testing.expectEqual("Lightpanda/1.0", res.header.get("_user-agent"));
2949+
try testing.expectEqual("*/*", res.header.get("_accept"));
29472950
}
29482951
}
29492952

@@ -2985,11 +2988,12 @@ test "HttpClient: sync GET redirect" {
29852988

29862989
try testing.expectEqual("over 9000!", try res.next());
29872990
try testing.expectEqual(201, res.header.status);
2988-
try testing.expectEqual(4, res.header.count());
2991+
try testing.expectEqual(5, res.header.count());
29892992
try testing.expectEqual("Close", res.header.get("connection"));
29902993
try testing.expectEqual("10", res.header.get("content-length"));
29912994
try testing.expectEqual("127.0.0.1", res.header.get("_host"));
29922995
try testing.expectEqual("Lightpanda/1.0", res.header.get("_user-agent"));
2996+
try testing.expectEqual("*/*", res.header.get("_accept"));
29932997
}
29942998

29952999
test "HttpClient: async connect error" {
@@ -3088,6 +3092,7 @@ test "HttpClient: async with body" {
30883092
"content-length", "10",
30893093
"_host", "127.0.0.1",
30903094
"_user-agent", "Lightpanda/1.0",
3095+
"_accept", "*/*",
30913096
"connection", "Close",
30923097
});
30933098
}
@@ -3141,6 +3146,7 @@ test "HttpClient: async redirect" {
31413146
"content-length", "10",
31423147
"_host", "127.0.0.1",
31433148
"_user-agent", "Lightpanda/1.0",
3149+
"_accept", "*/*",
31443150
"connection", "Close",
31453151
});
31463152
}
@@ -3213,6 +3219,7 @@ test "HttpClient: async redirect from TLS to Plaintext" {
32133219
"content-length", "10",
32143220
"_host", "127.0.0.1",
32153221
"_user-agent", "Lightpanda/1.0",
3222+
"_accept", "*/*",
32163223
"connection", "Close",
32173224
});
32183225
}

0 commit comments

Comments
 (0)