github.com/yandex/pandora@v0.5.32/components/providers/http/decoders/raw/decoder.go (about) 1 package raw 2 3 import ( 4 "bufio" 5 "bytes" 6 "fmt" 7 "net/http" 8 "strconv" 9 "strings" 10 ) 11 12 func DecodeHeader(headerString string) (reqSize int, tag string, err error) { 13 var sizeStr string 14 sizeStr, tag, _ = strings.Cut(headerString, " ") 15 reqSize, err = strconv.Atoi(sizeStr) 16 if err != nil { 17 return 0, "", fmt.Errorf("invalid payload size line `%s`. expect `%%d %%s`", headerString) 18 } 19 return reqSize, tag, err 20 } 21 22 func DecodeRequest(reqString []byte) (req *http.Request, err error) { 23 req, err = http.ReadRequest(bufio.NewReader(bytes.NewReader(reqString))) 24 if err != nil { 25 return 26 } 27 req.RequestURI = "" 28 return req, err 29 }