Skip to content

Commit b0746a1

Browse files
committed
Proper HTTP-Context
1 parent 48a8931 commit b0746a1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

logger.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ func (w logUploadingLogCloser) Close() error {
113113
return err
114114
}
115115
// Upload logfile to server
116-
req, err := http.NewRequestWithContext(context.TODO(), "POST", w.logUploadTarget, logData)
116+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
117+
defer cancel()
118+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, w.logUploadTarget, logData)
117119
if err != nil {
118120
return err
119121
}
122+
req.Header.Set("Content-Type", "application/octet-stream")
123+
120124
client := &http.Client{Timeout: 30 * time.Second}
121125
resp, err := client.Do(req)
122126
if err != nil {

0 commit comments

Comments
 (0)