@@ -32,9 +32,10 @@ func buildRequest(input metaRequest) (req request, err error) {
32
32
return
33
33
}
34
34
35
- body , bodyHeaders , bodyerr := buildBody (input )
36
- if bodyerr != nil {
37
- err = fmt .Errorf ("creating body %w" , bodyerr )
35
+ var body io.Reader
36
+ body , err = buildBody (& input )
37
+ if err != nil {
38
+ err = fmt .Errorf ("creating body %w" , err )
38
39
return
39
40
}
40
41
r , err = http .NewRequest (input .method , url , body )
@@ -45,10 +46,6 @@ func buildRequest(input metaRequest) (req request, err error) {
45
46
for header , value := range input .headers {
46
47
r .Header .Set (header , value )
47
48
}
48
- for header , value := range bodyHeaders {
49
- r .Header .Set (header , value )
50
- }
51
-
52
49
}
53
50
req = request {
54
51
label : input .label ,
@@ -69,7 +66,7 @@ func buildRequest(input metaRequest) (req request, err error) {
69
66
return
70
67
}
71
68
72
- func buildFileBody (input metaRequest ) (body * bytes.Buffer , headers map [ string ] string , err error ) {
69
+ func buildFileBody (input * metaRequest ) (body * bytes.Buffer , err error ) {
73
70
file , err := os .Open (input .filepath )
74
71
if err != nil {
75
72
return
@@ -91,11 +88,11 @@ func buildFileBody(input metaRequest) (body *bytes.Buffer, headers map[string]st
91
88
if err != nil {
92
89
return
93
90
}
94
-
95
- return body , map [ string ] string { "Content-Type" : writer . FormDataContentType ()}, err
91
+ input . headers [ "Content-Type" ] = writer . FormDataContentType ()
92
+ return body , err
96
93
}
97
94
98
- func buildBody (input metaRequest ) (body io.Reader , headers map [ string ] string , err error ) {
95
+ func buildBody (input * metaRequest ) (body io.Reader , err error ) {
99
96
if input .filepath != "" {
100
97
return buildFileBody (input )
101
98
}
0 commit comments