Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tednaleid committed Aug 21, 2018
1 parent ddbee46 commit 2f54955
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ func createApp() *cli.App {
}

func run(context *execcontext.Context) {
requestsChannel := make(chan *http.Request)
responsesChannel := make(chan *http.Response)
bufferSize := 256
requestsChannel := make(chan *http.Request, bufferSize)
responsesChannel := make(chan *http.Response, bufferSize)

requestWaitGroup := requests.StartRequestWorkers(requestsChannel, responsesChannel, context)
responseWaitGroup := responses.StartResponseWorkers(responsesChannel, context)
Expand Down
6 changes: 3 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func SendRequests(context *execcontext.Context, requests chan<- *http.Request) {
<-throttle
}

if (context.DataTemplate == "") {
if context.DataTemplate == "" {
url, body = ParseUrlAndOptionalBody(requestScanner.Text())
} else {
url, body = ParseTemplatedInput(requestScanner.Text(), context.DataTemplate)
Expand All @@ -40,7 +40,7 @@ func ParseUrlAndOptionalBody(input string) (string, io.Reader) {

url := tokens[0]

if (len(tokens) == 1) {
if len(tokens) == 1 {
return url, nil // no body, just an url
}

Expand All @@ -54,7 +54,7 @@ func ParseTemplatedInput(input string, dataTemplate string) (string, io.Reader){

url := tokens[0]

if (len(tokens) == 1) {
if len(tokens) == 1 {
return url, strings.NewReader(dataTemplate) // just an url, static body
}

Expand Down
2 changes: 1 addition & 1 deletion responses/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func printResponse(response *http.Response, context *execcontext.Context) {
buf := new(bytes.Buffer)
buf.ReadFrom(response.Body)

if (context.JsonEnvelope) {
if context.JsonEnvelope {
if buf.Len() > 0 {
context.Out.Printf("{ \"url\": \"%s\", \"code\": %d, \"length\": %d, \"body\": %s }", response.Request.URL.String(), response.StatusCode, buf.Len(), buf)

Expand Down

0 comments on commit 2f54955

Please sign in to comment.