-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into floitsch/add_content_size
- Loading branch information
Showing
8 changed files
with
78 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2023 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/TESTS_LICENSE file. | ||
import certificate_roots show * | ||
import expect show * | ||
import http | ||
import net | ||
|
||
HOST ::= "google.com" | ||
PATH ::= "/nogood" | ||
CODE ::= 404 | ||
|
||
main: | ||
network := net.open | ||
client := http.Client.tls network | ||
|
||
client.root_certificates_.add GTS_ROOT_R1 | ||
|
||
response := client.get --host=HOST --path=PATH | ||
|
||
expect_equals CODE response.status_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (C) 2023 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/TESTS_LICENSE file. | ||
import certificate_roots | ||
import expect show * | ||
import http | ||
import net | ||
|
||
URI ::= "wss://echo.websocket.events/" | ||
// This header is required by the WebSocket endpoint. | ||
ORIGIN ::= { "Origin": "http://echo.websocket.events" } | ||
MSG1 ::= "Hello, from Toit!" | ||
MSG2 ::= #[0xff, 0x00, 103] | ||
|
||
main: | ||
network := net.open | ||
client := http.Client network --root_certificates=[certificate_roots.ISRG_ROOT_X1] | ||
web_socket := client.web_socket --uri=URI --headers=(http.Headers.from_map ORIGIN) | ||
greeting := web_socket.receive | ||
expect_equals "echo.websocket.events sponsored by Lob.com" greeting | ||
print greeting | ||
web_socket.send MSG1 | ||
echo := web_socket.receive | ||
expect_equals MSG1 echo | ||
web_socket.send MSG2 | ||
echo_bytes := web_socket.receive | ||
expect_equals MSG2 echo_bytes |