Skip to content

Commit

Permalink
Do not print request without -v flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
rs committed Aug 7, 2018
1 parent 4d4337a commit f268a7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions formatter/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ func (c *HeaderCleaner) Write(p []byte) (n int, err error) {
ignore := false
b, i := firstVisibleChar(c.line)
switch b {
case '>', '<':
case '>':
if c.Verbose {
c.line = c.line[i+2:]
} else {
ignore = true
}
case '<':
c.line = c.line[i+2:]
case '}', '{':
ignore = true
if c.Post != nil {
if c.Verbose && c.Post != nil {
cp = append(append(cp, bytes.TrimSpace(c.Post.Bytes())...), '\n', '\n')
c.Post = nil
}
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func main() {
Scheme: formatter.DefaultColorScheme,
}
}
hasInput := true
if data := opts.Val("d"); data != "" {
// If data is provided via -d, read it from there for the verbose mode.
// XXX handle the @filename case.
Expand All @@ -76,8 +77,14 @@ func main() {
opts = append(opts, "-d@-")
// Tee the stdin to the buffer used show the posted data in verbose mode.
stdin = io.TeeReader(stdin, inputWriter)
} else {
hasInput = false
}
if hasInput {
opts = append(opts, "-H", "Content-Type: application/json")
}
}
opts = append(opts, "-H", "Accept: application/json, */*")
if opts.Has("curl") {
opts.Remove("curl")
fmt.Printf("curl %s\n", strings.Join(opts, " "))
Expand Down

0 comments on commit f268a7a

Please sign in to comment.