Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat main.go
- package main
- import (
- "flag"
- "fmt"
- "io"
- "net/http"
- )
- func main() {
- read := flag.Bool("read", false, "to read or not to read")
- flag.Parse()
- resp, _ := http.Get("https://www.google.com")
- defer resp.Body.Close()
- if *read {
- io.ReadAll(resp.Body)
- }
- fmt.Print(resp.Status)
- }
- $ GODEBUG=http2debug=1 go run main.go
- 2024/10/30 20:58:33 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
- 2024/10/30 20:58:33 http2: Transport creating client conn 0x4000136000 to 142.251.39.100:443
- 2024/10/30 20:58:33 http2: Transport encoding header ":authority" = "www.google.com"
- 2024/10/30 20:58:33 http2: Transport encoding header ":method" = "GET"
- 2024/10/30 20:58:33 http2: Transport encoding header ":path" = "/"
- 2024/10/30 20:58:33 http2: Transport encoding header ":scheme" = "https"
- 2024/10/30 20:58:33 http2: Transport encoding header "accept-encoding" = "gzip"
- 2024/10/30 20:58:33 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
- 2024/10/30 20:58:33 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
- 2024/10/30 20:58:33 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
- 2024/10/30 20:58:33 http2: Transport received SETTINGS flags=ACK len=0
- 2024/10/30 20:58:33 http2: Transport received HEADERS flags=END_HEADERS stream=1 len=846
- 200 OK
- $ GODEBUG=http2debug=1 go run main.go -read
- 2024/10/30 20:58:37 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
- 2024/10/30 20:58:37 http2: Transport creating client conn 0x4000216000 to 142.251.39.100:443
- 2024/10/30 20:58:37 http2: Transport encoding header ":authority" = "www.google.com"
- 2024/10/30 20:58:37 http2: Transport encoding header ":method" = "GET"
- 2024/10/30 20:58:37 http2: Transport encoding header ":path" = "/"
- 2024/10/30 20:58:37 http2: Transport encoding header ":scheme" = "https"
- 2024/10/30 20:58:37 http2: Transport encoding header "accept-encoding" = "gzip"
- 2024/10/30 20:58:37 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
- 2024/10/30 20:58:37 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
- 2024/10/30 20:58:37 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
- 2024/10/30 20:58:37 http2: Transport received SETTINGS flags=ACK len=0
- 2024/10/30 20:58:37 http2: Transport received HEADERS flags=END_HEADERS stream=1 len=844
- 2024/10/30 20:58:37 http2: Transport received DATA flags=PADDED stream=1 len=5932 data="\x1f\(5569 bytes omitted)
- 2024/10/30 20:58:37 http2: Transport received DATA flags=PADDED stream=1 len=305
- 2024/10/30 20:58:37 http2: Transport received DATA flags=PADDED stream=1 len=3485 data="ӏ_6\x81!" (3209 bytes omitted)
- 2024/10/30 20:58:37 http2: Transport received DATA flags=END_STREAM stream=1 len=0 data=""
- 2024/10/30 20:58:37 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x020"
- 200 OK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement