Standard library / net/http
http.Request.WriteProxy()
Serializes a request in HTTP/1 proxy form, including an absolute request target. No proxy connection is made. Expected stdout: 'GET http://example.invalid/a HTTP/1.1\n'.
Formal Syntax & Structure
go syntaxgo
func (r *Request) WriteProxy(w io.Writer) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | io.Writer | Destination writer. |
Return Value
error
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "net/http" "strings")
func main() { r := must(http.NewRequest("GET", "http://example.invalid/a", nil)) var b bytes.Buffer check(r.WriteProxy(&b)) fmt.Println(strings.Split(b.String(), "\r\n")[0])}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}