mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-19 07:01:02 +01:00
893a555051
This reverts commit cd1aca217c
.
Reason for revert: this commit has no sense, since the firehose response has application/json content-type,
so it must contain JSON-encoded timestamp and requestId fields according to https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html#responseformat .
HTML-escaping the requestId field may break the response, so the client couldn't correctly recognize the html-escaped requestId.
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/6451
27 lines
744 B
Go
27 lines
744 B
Go
package firehose
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// WriteSuccessResponse writes success response for AWS Firehose request.
|
|
//
|
|
// See https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html#responseformat
|
|
func WriteSuccessResponse(w http.ResponseWriter, r *http.Request) {
|
|
requestID := r.Header.Get("X-Amz-Firehose-Request-Id")
|
|
if requestID == "" {
|
|
// This isn't a AWS firehose request - just return an empty response in this case.
|
|
w.WriteHeader(http.StatusOK)
|
|
return
|
|
}
|
|
|
|
body := fmt.Sprintf(`{"requestId":%q,"timestamp":%d}`, requestID, time.Now().UnixMilli())
|
|
|
|
h := w.Header()
|
|
h.Set("Content-Type", "application/json")
|
|
h.Set("Content-Length", fmt.Sprintf("%d", len(body)))
|
|
w.Write([]byte(body))
|
|
}
|