escape strings in Go generator (#381)

This commit is contained in:
Boris Verkhovskiy
2022-04-12 18:53:48 -07:00
committed by GitHub
parent ac70a67e55
commit 1640ca881a
3 changed files with 68 additions and 22 deletions

View File

@@ -0,0 +1,4 @@
# https://github.com/curlconverter/curlconverter/issues/272
curl 'http://localhost:28139' \
-H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="92"' \
--compressed

View File

@@ -0,0 +1,27 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
client := &http.Client{}
req, err := http.NewRequest("GET", "http://localhost:28139", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("sec-ch-ua", `" Not A;Brand";v="99", "Chromium";v="92"`)
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}