1 回答

TA貢獻1820條經驗 獲得超10個贊
http 標頭必須以 結尾,但似乎可以用于 ?下面的代碼確實有效。\r\n\r\n\nhttp.ReadRequest
package main
import (
"bufio"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
stra := `GET / HTTP/1.1
Host: google.com
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Connection: close
`
req, err := http.ReadRequest(bufio.NewReader(strings.NewReader(stra)))
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
fmt.Println(req)
}
- 1 回答
- 0 關注
- 271 瀏覽
添加回答
舉報