Advertisement
Guest User

Untitled

a guest
Oct 30th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.44 KB | None | 0 0
  1. $ cat main.go
  2.  
  3. package main
  4.  
  5. import (
  6. "flag"
  7. "fmt"
  8. "io"
  9. "net/http"
  10. )
  11.  
  12. func main() {
  13. read := flag.Bool("read", false, "to read or not to read")
  14. flag.Parse()
  15. resp, _ := http.Head("https://www.google.com") // only changed to .Head
  16. defer resp.Body.Close()
  17. if *read {
  18. io.ReadAll(resp.Body)
  19. }
  20. fmt.Print(resp.Status)
  21. }
  22.  
  23.  
  24. $ ./script.sh
  25. 2024/10/30 16:37:24 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  26. 2024/10/30 16:37:24 http2: Transport creating client conn 0x140001bc000 to 142.250.31.99:443
  27. 2024/10/30 16:37:24 http2: Transport encoding header ":authority" = "www.google.com"
  28. 2024/10/30 16:37:24 http2: Transport encoding header ":method" = "HEAD"
  29. 2024/10/30 16:37:24 http2: Transport encoding header ":path" = "/"
  30. 2024/10/30 16:37:24 http2: Transport encoding header ":scheme" = "https"
  31. 2024/10/30 16:37:24 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  32. 2024/10/30 16:37:24 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  33. 2024/10/30 16:37:24 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  34. 2024/10/30 16:37:24 http2: Transport received SETTINGS flags=ACK len=0
  35. 2024/10/30 16:37:24 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=787
  36. 2024/10/30 16:37:24 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x01\xc7"
  37. 200 OK2024/10/30 16:37:25 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  38. 2024/10/30 16:37:25 http2: Transport creating client conn 0x140000ea000 to 142.250.31.99:443
  39. 2024/10/30 16:37:25 http2: Transport encoding header ":authority" = "www.google.com"
  40. 2024/10/30 16:37:25 http2: Transport encoding header ":method" = "HEAD"
  41. 2024/10/30 16:37:25 http2: Transport encoding header ":path" = "/"
  42. 2024/10/30 16:37:25 http2: Transport encoding header ":scheme" = "https"
  43. 2024/10/30 16:37:25 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  44. 2024/10/30 16:37:25 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  45. 2024/10/30 16:37:25 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  46. 2024/10/30 16:37:25 http2: Transport received SETTINGS flags=ACK len=0
  47. 2024/10/30 16:37:25 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=787
  48. 2024/10/30 16:37:25 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x02\x18"
  49. 200 OK2024/10/30 16:37:25 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  50. 2024/10/30 16:37:25 http2: Transport creating client conn 0x140000f4000 to 142.250.31.99:443
  51. 2024/10/30 16:37:25 http2: Transport encoding header ":authority" = "www.google.com"
  52. 2024/10/30 16:37:25 http2: Transport encoding header ":method" = "HEAD"
  53. 2024/10/30 16:37:25 http2: Transport encoding header ":path" = "/"
  54. 2024/10/30 16:37:25 http2: Transport encoding header ":scheme" = "https"
  55. 2024/10/30 16:37:25 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  56. 2024/10/30 16:37:25 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  57. 2024/10/30 16:37:25 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  58. 2024/10/30 16:37:25 http2: Transport received SETTINGS flags=ACK len=0
  59. 2024/10/30 16:37:25 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=786
  60. 2024/10/30 16:37:25 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x02n"
  61. 200 OK2024/10/30 16:37:26 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  62. 2024/10/30 16:37:26 http2: Transport creating client conn 0x1400012a000 to 142.250.31.99:443
  63. 2024/10/30 16:37:26 http2: Transport encoding header ":authority" = "www.google.com"
  64. 2024/10/30 16:37:26 http2: Transport encoding header ":method" = "HEAD"
  65. 2024/10/30 16:37:26 http2: Transport encoding header ":path" = "/"
  66. 2024/10/30 16:37:26 http2: Transport encoding header ":scheme" = "https"
  67. 2024/10/30 16:37:26 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  68. 2024/10/30 16:37:26 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  69. 2024/10/30 16:37:26 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  70. 2024/10/30 16:37:26 http2: Transport received SETTINGS flags=ACK len=0
  71. 2024/10/30 16:37:26 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=787
  72. 2024/10/30 16:37:26 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x02\xdb"
  73. 200 OK2024/10/30 16:37:26 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  74. 2024/10/30 16:37:26 http2: Transport creating client conn 0x140000c6000 to 142.250.31.99:443
  75. 2024/10/30 16:37:26 http2: Transport encoding header ":authority" = "www.google.com"
  76. 2024/10/30 16:37:26 http2: Transport encoding header ":method" = "HEAD"
  77. 2024/10/30 16:37:26 http2: Transport encoding header ":path" = "/"
  78. 2024/10/30 16:37:26 http2: Transport encoding header ":scheme" = "https"
  79. 2024/10/30 16:37:26 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  80. 2024/10/30 16:37:26 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  81. 2024/10/30 16:37:26 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  82. 2024/10/30 16:37:26 http2: Transport received SETTINGS flags=ACK len=0
  83. 2024/10/30 16:37:26 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=786
  84. 2024/10/30 16:37:26 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x03\xb9"
  85. 200 OK2024/10/30 16:37:27 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  86. 2024/10/30 16:37:27 http2: Transport creating client conn 0x1400023c000 to 142.250.31.99:443
  87. 2024/10/30 16:37:27 http2: Transport encoding header ":authority" = "www.google.com"
  88. 2024/10/30 16:37:27 http2: Transport encoding header ":method" = "HEAD"
  89. 2024/10/30 16:37:27 http2: Transport encoding header ":path" = "/"
  90. 2024/10/30 16:37:27 http2: Transport encoding header ":scheme" = "https"
  91. 2024/10/30 16:37:27 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  92. 2024/10/30 16:37:27 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  93. 2024/10/30 16:37:27 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  94. 2024/10/30 16:37:27 http2: Transport received SETTINGS flags=ACK len=0
  95. 2024/10/30 16:37:27 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=783
  96. 2024/10/30 16:37:27 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x00\\"
  97. 200 OK2024/10/30 16:37:27 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  98. 2024/10/30 16:37:27 http2: Transport creating client conn 0x1400025e000 to 142.250.31.99:443
  99. 2024/10/30 16:37:27 http2: Transport encoding header ":authority" = "www.google.com"
  100. 2024/10/30 16:37:27 http2: Transport encoding header ":method" = "HEAD"
  101. 2024/10/30 16:37:27 http2: Transport encoding header ":path" = "/"
  102. 2024/10/30 16:37:27 http2: Transport encoding header ":scheme" = "https"
  103. 2024/10/30 16:37:27 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  104. 2024/10/30 16:37:27 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  105. 2024/10/30 16:37:27 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  106. 2024/10/30 16:37:27 http2: Transport received SETTINGS flags=ACK len=0
  107. 2024/10/30 16:37:27 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=786
  108. 2024/10/30 16:37:27 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x01="
  109. 200 OK2024/10/30 16:37:28 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  110. 2024/10/30 16:37:28 http2: Transport creating client conn 0x140001bc000 to 142.250.31.99:443
  111. 2024/10/30 16:37:28 http2: Transport encoding header ":authority" = "www.google.com"
  112. 2024/10/30 16:37:28 http2: Transport encoding header ":method" = "HEAD"
  113. 2024/10/30 16:37:28 http2: Transport encoding header ":path" = "/"
  114. 2024/10/30 16:37:28 http2: Transport encoding header ":scheme" = "https"
  115. 2024/10/30 16:37:28 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  116. 2024/10/30 16:37:28 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  117. 2024/10/30 16:37:28 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  118. 2024/10/30 16:37:28 http2: Transport received SETTINGS flags=ACK len=0
  119. 2024/10/30 16:37:28 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=784
  120. 2024/10/30 16:37:28 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x01\xd6"
  121. 200 OK2024/10/30 16:37:28 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  122. 2024/10/30 16:37:28 http2: Transport creating client conn 0x140000f4000 to 142.250.31.99:443
  123. 2024/10/30 16:37:28 http2: Transport encoding header ":authority" = "www.google.com"
  124. 2024/10/30 16:37:28 http2: Transport encoding header ":method" = "HEAD"
  125. 2024/10/30 16:37:28 http2: Transport encoding header ":path" = "/"
  126. 2024/10/30 16:37:28 http2: Transport encoding header ":scheme" = "https"
  127. 2024/10/30 16:37:28 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  128. 2024/10/30 16:37:28 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  129. 2024/10/30 16:37:28 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  130. 2024/10/30 16:37:28 http2: Transport received SETTINGS flags=ACK len=0
  131. 2024/10/30 16:37:28 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=786
  132. 2024/10/30 16:37:28 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x03C"
  133. 200 OK2024/10/30 16:37:29 http2: Transport failed to get client conn for www.google.com:443: http2: no cached connection was available
  134. 2024/10/30 16:37:29 http2: Transport creating client conn 0x140001e6000 to 142.250.31.99:443
  135. 2024/10/30 16:37:29 http2: Transport encoding header ":authority" = "www.google.com"
  136. 2024/10/30 16:37:29 http2: Transport encoding header ":method" = "HEAD"
  137. 2024/10/30 16:37:29 http2: Transport encoding header ":path" = "/"
  138. 2024/10/30 16:37:29 http2: Transport encoding header ":scheme" = "https"
  139. 2024/10/30 16:37:29 http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
  140. 2024/10/30 16:37:29 http2: Transport received SETTINGS len=18, settings: MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536
  141. 2024/10/30 16:37:29 http2: Transport received WINDOW_UPDATE len=4 (conn) incr=983041
  142. 2024/10/30 16:37:29 http2: Transport received SETTINGS flags=ACK len=0
  143. 2024/10/30 16:37:29 http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=1 len=786
  144. 2024/10/30 16:37:29 http2: Transport received PING len=8 ping="\x00\x00\x00\x00\x00\x00\x03\xaf"
  145. 200 OK%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement