Vendor integration dependencies.
This commit is contained in:
parent
dd5e3fba01
commit
55b57c736b
2451 changed files with 731611 additions and 0 deletions
22
integration/vendor/github.com/moul/http2curl/LICENSE
generated
vendored
Normal file
22
integration/vendor/github.com/moul/http2curl/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Manfred Touron
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
74
integration/vendor/github.com/moul/http2curl/http2curl.go
generated
vendored
Normal file
74
integration/vendor/github.com/moul/http2curl/http2curl.go
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
package http2curl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CurlCommand contains exec.Command compatible slice + helpers
|
||||
type CurlCommand struct {
|
||||
slice []string
|
||||
}
|
||||
|
||||
// append appends a string to the CurlCommand
|
||||
func (c *CurlCommand) append(newSlice ...string) {
|
||||
c.slice = append(c.slice, newSlice...)
|
||||
}
|
||||
|
||||
// String returns a ready to copy/paste command
|
||||
func (c *CurlCommand) String() string {
|
||||
slice := make([]string, len(c.slice))
|
||||
copy(slice, c.slice)
|
||||
for i := range slice {
|
||||
quoted := fmt.Sprintf("%q", slice[i])
|
||||
if strings.Contains(slice[i], " ") || len(quoted) != len(slice[i])+2 {
|
||||
slice[i] = quoted
|
||||
}
|
||||
}
|
||||
return strings.Join(slice, " ")
|
||||
}
|
||||
|
||||
// nopCloser is used to create a new io.ReadCloser for req.Body
|
||||
type nopCloser struct {
|
||||
io.Reader
|
||||
}
|
||||
|
||||
func (nopCloser) Close() error { return nil }
|
||||
|
||||
// GetCurlCommand returns a CurlCommand corresponding to an http.Request
|
||||
func GetCurlCommand(req *http.Request) (*CurlCommand, error) {
|
||||
command := CurlCommand{}
|
||||
|
||||
command.append("curl")
|
||||
|
||||
command.append("-X", req.Method)
|
||||
|
||||
if req.Body != nil {
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Body = nopCloser{bytes.NewBuffer(body)}
|
||||
command.append("-d", fmt.Sprintf("%s", bytes.Trim(body, "\n")))
|
||||
}
|
||||
|
||||
var keys []string
|
||||
|
||||
for k := range req.Header {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, k := range keys {
|
||||
command.append("-H", fmt.Sprintf("%s: %s", k, strings.Join(req.Header[k], " ")))
|
||||
}
|
||||
|
||||
command.append(fmt.Sprintf("'%v'", req.URL.String()))
|
||||
|
||||
return &command, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue