Golang net/http.ReadRequest() function example
package net/http
Golang net/http.ReadRequest() function usage example
package main
import (
"bufio"
"fmt"
"net/http"
"bytes"
)
func main() {
readbuffer := bytes.NewBuffer([]byte("GET / HTTP/1.1\r\nheader:foo\r\n\r\n"))
reader := bufio.NewReader(readbuffer)
req, err := http.ReadRequest(reader)
if err != nil {
panic(err)
}
fmt.Println(req)
}
output :
&{GET / HTTP/1.1 1 1 map[Header:[foo]] 0x7e4380 0 [] false map[] map[]
map[] / }
References :
http://golang.org/pkg/net/http/#ReadRequest
https://www.socketloop.com/references/golang-bufio-newreader-function-example
Advertisement
Something interesting
Tutorials
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+32.1k Golang : Validate email address with regular expression
+6.9k Golang : Pat multiplexer routing example
+13.6k Golang : Set image canvas or background to transparent
+8.8k Yum Error: no such table: packages
+5.6k PHP : Convert CSV to JSON with YQL example
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+5.9k Golang : Shuffle array of list
+7.2k Golang : Null and nil value
+8.2k Golang : Get final or effective URL with Request.URL example
+14.6k Golang : How to get URL port?
+6.1k Golang : Measure execution time for a function