mirror of
https://github.com/alvierahman90/gohookr.git
synced 2025-10-13 07:24:22 +00:00
AppendHeaders
This commit is contained in:
@@ -2,22 +2,33 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
Program string
|
||||
Arguments []string
|
||||
AppendPayload bool
|
||||
AppendHeaders bool
|
||||
}
|
||||
|
||||
func (c Command) Execute(payload string) ([]byte, error) {
|
||||
func (c Command) Execute(payload string, header http.Header) ([]byte, error) {
|
||||
arguments := make([]string, 0)
|
||||
copy(c.Arguments, arguments)
|
||||
|
||||
if c.AppendPayload {
|
||||
arguments = append(arguments, payload)
|
||||
}
|
||||
|
||||
if c.AppendHeaders {
|
||||
var header_builder strings.Builder;
|
||||
header.Write(&header_builder);
|
||||
|
||||
arguments = append(arguments, header_builder.String())
|
||||
}
|
||||
|
||||
return exec.Command(c.Program, arguments...).Output()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user