Skip to content

Commit

Permalink
Minor fixes to BuildMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
mkpercip committed Jun 13, 2024
1 parent 8f08687 commit 41370a2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions command/call/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ package call

import (
"fmt"
"github.com/percipia/eslgo/command"
"net/textproto"
"strconv"

"github.com/percipia/eslgo/command"
)

type Execute struct {
Expand Down Expand Up @@ -73,7 +74,7 @@ func (e *Execute) BuildMessage() string {
}
sendMsg := command.SendMessage{
UUID: e.UUID,
Headers: make(textproto.MIMEHeader),
Headers: make(textproto.MIMEHeader, 4), // preallocating for the 4+ headers that are always set to reduce amount of dynamic allocations
Sync: e.Sync,
SyncPri: e.SyncPri,
}
Expand All @@ -87,8 +88,8 @@ func (e *Execute) BuildMessage() string {

// According to documentation that is the max header length
if len(e.AppArgs) > 2048 || e.ForceBody {
sendMsg.Headers.Set("content-type", "text/plain")
sendMsg.Headers.Set("content-length", strconv.Itoa(len(e.AppArgs)))
sendMsg.Headers.Set("Content-Type", "text/plain")
sendMsg.Headers.Set("Content-Length", strconv.Itoa(len(e.AppArgs)))
sendMsg.Body = e.AppArgs
} else {
sendMsg.Headers.Set("execute-app-arg", e.AppArgs)
Expand Down

0 comments on commit 41370a2

Please sign in to comment.