Advertisement
Guest User

Untitled

a guest
Oct 30th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. $ cat main.go
  2. package main
  3.  
  4. import (
  5. "flag"
  6. "fmt"
  7. "io"
  8. "net/http"
  9. )
  10.  
  11. func main() {
  12. read := flag.Bool("read", false, "to read or not to read")
  13. flag.Parse()
  14. resp, _ := http.Get("https://www.google.com")
  15. defer resp.Body.Close()
  16. if *read {
  17. io.ReadAll(resp.Body)
  18. }
  19. fmt.Print(resp.Status)
  20. }
  21.  
  22.  
  23. $ GODEBUG=http2debug=1 go run main.go
  24. 2024/10/30 20:58:33 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  25. 2024/10/30 20:58:33 http2: Transport creating client conn 0x4000136000 to 142.251.39.100:443
  26. 2024/10/30 20:58:33 http2: Transport encoding header ":authority" = "www.google.com"
  27. 2024/10/30 20:58:33 http2: Transport encoding header ":method" = "GET"
  28. 2024/10/30 20:58:33 http2: Transport encoding header ":path" = "/"
  29. 2024/10/30 20:58:33 http2: Transport encoding header ":scheme" = "https"
  30. 2024/10/30 20:58:33 http2: Transport encoding header "accept-encoding" = "gzip"
  31. 2024/10/30 20:58:33 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  32. 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
  33. 2024/10/30 20:58:33 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  34. 2024/10/30 20:58:33 http2: Transport received SETTINGS flags=ACK len=0
  35. 2024/10/30 20:58:33 http2: Transport received HEADERS flags=END_HEADERS stream=1 len=846
  36. 200 OK
  37.  
  38.  
  39. $ GODEBUG=http2debug=1 go run main.go -read
  40. 2024/10/30 20:58:37 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  41. 2024/10/30 20:58:37 http2: Transport creating client conn 0x4000216000 to 142.251.39.100:443
  42. 2024/10/30 20:58:37 http2: Transport encoding header ":authority" = "www.google.com"
  43. 2024/10/30 20:58:37 http2: Transport encoding header ":method" = "GET"
  44. 2024/10/30 20:58:37 http2: Transport encoding header ":path" = "/"
  45. 2024/10/30 20:58:37 http2: Transport encoding header ":scheme" = "https"
  46. 2024/10/30 20:58:37 http2: Transport encoding header "accept-encoding" = "gzip"
  47. 2024/10/30 20:58:37 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  48. 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
  49. 2024/10/30 20:58:37 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  50. 2024/10/30 20:58:37 http2: Transport received SETTINGS flags=ACK len=0
  51. 2024/10/30 20:58:37 http2: Transport received HEADERS flags=END_HEADERS stream=1 len=844
  52. 2024/10/30 20:58:37 http2: Transport received DATA flags=PADDED stream=1 len=5932 data="\x1f\(5569 bytes omitted)
  53. 2024/10/30 20:58:37 http2: Transport received DATA flags=PADDED stream=1 len=305
  54. 2024/10/30 20:58:37 http2: Transport received DATA flags=PADDED stream=1 len=3485 data="ӏ_6\x81!" (3209 bytes omitted)
  55. 2024/10/30 20:58:37 http2: Transport received DATA flags=END_STREAM stream=1 len=0 data=""
  56. 2024/10/30 20:58:37 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x020"
  57. 200 OK
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement