mirror of
https://github.com/curlconverter/curlconverter.git
synced 2022-05-22 02:35:29 +03:00
escape strings in Go generator (#381)
This commit is contained in:
committed by
GitHub
parent
ac70a67e55
commit
1640ca881a
4
test/fixtures/curl_commands/get_header_with_quotes.sh
vendored
Normal file
4
test/fixtures/curl_commands/get_header_with_quotes.sh
vendored
Normal 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
|
||||
27
test/fixtures/go/get_header_with_quotes.go
vendored
Normal file
27
test/fixtures/go/get_header_with_quotes.go
vendored
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user