Skip to content

Commit

Permalink
Support curl --insecure option to skip ssl check
Browse files Browse the repository at this point in the history
  • Loading branch information
dcb9 committed Dec 21, 2022
1 parent 63fcd31 commit ae34c0c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions connector/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var curl2HttpieTransformerMap = map[curl.LongName]httpieTransformer.Transformer{
"verbose": httpieTransformer.Verbose,
"referer": httpieTransformer.Referer,
"cookie": httpieTransformer.Cookie,
"insecure": httpieTransformer.Verify,
}

func Curl2Httpie(args []string) (cmdStringer fmt.Stringer, warningMessages []WarningMessage, err error) {
Expand Down
18 changes: 12 additions & 6 deletions httpie/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@ package httpie

import (
"fmt"

flag "github.com/spf13/pflag"
)

type Flag struct {
Long string
Short byte
HasArg bool
Arg string
Long string
Short byte
HasArg bool
Arg string
Separator string
}

func (f *Flag) SetShort(s byte) {
f.Short = s
}

func (f *Flag) SetArg(arg string) {
func (f *Flag) SetArg(arg string, separator string) {
f.HasArg = true
f.Arg = arg
f.Separator = separator
}

func (f *Flag) String() string {
arg := ""
if f.HasArg {
arg = fmt.Sprintf(` '%s'`, f.Arg)
if f.Separator == "" {
f.Separator = " " // Use whitespace as default separator
}
arg = fmt.Sprintf(`%s%s`, f.Separator, f.Arg)
}
return fmt.Sprintf("--%s%s", f.Long, arg)
}
Expand Down
8 changes: 7 additions & 1 deletion transformers/httpie/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func URL(cl *httpie.CmdLine, o *curl.Option) {

func User(cl *httpie.CmdLine, o *curl.Option) {
f := httpie.NewFlag("auth")
f.SetArg(o.Arg)
f.SetArg(o.Arg, " ")

cl.AddFlag(f)
}
Expand All @@ -104,5 +104,11 @@ func Cookie(cl *httpie.CmdLine, o *curl.Option) {
cl.AddItem(h)
}

func Verify(cl *httpie.CmdLine, o *curl.Option) {
h := httpie.NewFlag("verify")
h.SetArg("no", "=")
cl.AddFlag(h)
}

func Noop(cl *httpie.CmdLine, o *curl.Option) {
}

0 comments on commit ae34c0c

Please sign in to comment.