File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -436,6 +436,11 @@ func (cli *CLIArgs) GetHTTPRequest() (*httprequest.HTTPRequest, error) {
436436 var url string
437437
438438 url = cli .buildURL ()
439+ var stat os.FileInfo
440+ var staterr error
441+ if os .Stdin != nil {
442+ stat , staterr = os .Stdin .Stat ()
443+ }
439444
440445 // TODO: is command == "" required?
441446 if ! cli .IsHelp && (cli .Command == AddCommand ||
@@ -445,8 +450,10 @@ func (cli *CLIArgs) GetHTTPRequest() (*httprequest.HTTPRequest, error) {
445450 url0 , body0 := cli .buildSingleParamBody ()
446451 url += url0
447452 body = body0
448- } else {
449- // if there is text on the standard input that'll used as the body
453+ } else if os .Stdin != nil && staterr == nil &&
454+ stat .Mode () & os .ModeCharDevice == 0 && stat .Size () > 0 {
455+ // os.ModeCharDevice flag is set when piping text to the stdin
456+ // use text in the standard input as body
450457 var buffer bytes.Buffer
451458 reader := bufio .NewReader (os .Stdin )
452459 text , _ := reader .ReadString ('\n' )
@@ -465,6 +472,8 @@ func (cli *CLIArgs) GetHTTPRequest() (*httprequest.HTTPRequest, error) {
465472 } else {
466473 body = cli .buildBody ()
467474 }
475+ } else {
476+ body = cli .buildBody ()
468477 }
469478 }
470479
You can’t perform that action at this time.
0 commit comments