Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"lib/forge-std": {
"rev": "3b20d60d14b343ee4f908cb8079495c07f5e8981"
},
"lib/solidity-stringutils": {
"rev": "4b2fcc43fa0426e19ce88b1f1ec16f5903a2e461"
}
}
2 changes: 1 addition & 1 deletion src/HTTP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ library HTTP {
}

function request(Request storage req) internal returns (Response memory res) {
string memory scriptStart = 'response=$(curl -s -w "\\n%{http_code}" ';
string memory scriptStart = 'response=$(curl -sL --max-redirs 3 --proto-redir =https -w "\\n%{http_code}" ';
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --proto-redir flag has incorrect syntax. There should be no space between the equals sign and the protocol value. The correct syntax is --proto-redir=https (without the space). With the current syntax, curl will likely fail or ignore this security safeguard, potentially allowing protocol downgrades from HTTPS to HTTP.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new redirect functionality lacks test coverage. Since the test suite in test/HTTP.t.sol contains comprehensive tests for other HTTP features, consider adding a test case that verifies redirect behavior works correctly. This could test that a URL returning a 3xx redirect status is properly followed, and that the final response is returned rather than the redirect response.

Copilot uses AI. Check for mistakes.
string memory scriptEnd =
'); status=$(tail -n1 <<< "$response"); data=$(sed "$ d" <<< "$response");data=$(echo "$data" | tr -d "\\n"); cast abi-encode "response(uint256,string)" "$status" "$data";';

Expand Down
6 changes: 3 additions & 3 deletions test/HTTP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ contract HTTPTest is Test {
}

function test_HTTP_GET_options() public {
HTTP.Response memory res = http.initialize("https://httpbin.org/headers").GET().withHeader(
"accept", "application/json"
).withHeader("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==").request();
HTTP.Response memory res = http.initialize("https://httpbin.org/headers").GET()
.withHeader("accept", "application/json").withHeader("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
.request();

assertEq(res.status, 200);

Expand Down