mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Merge pull request #751 from harshavardhana/pr_out_return_x_amz_request_id_for_all_replies
Return x-amz-request-id for all replies
This commit is contained in:
commit
74853caf0c
@ -74,7 +74,7 @@ func parseDate(req *http.Request) (time.Time, error) {
|
|||||||
return time.Time{}, errors.New("invalid request")
|
return time.Time{}, errors.New("invalid request")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidContentTypeHandler -
|
// ValidContentTypeHandler to validate Accept type
|
||||||
func ValidContentTypeHandler(h http.Handler) http.Handler {
|
func ValidContentTypeHandler(h http.Handler) http.Handler {
|
||||||
return contentTypeHandler{h}
|
return contentTypeHandler{h}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ func (h contentTypeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
h.handler.ServeHTTP(w, r)
|
h.handler.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimeValidityHandler -
|
// TimeValidityHandler to validate parsable time over http header
|
||||||
func TimeValidityHandler(h http.Handler) http.Handler {
|
func TimeValidityHandler(h http.Handler) http.Handler {
|
||||||
return timeHandler{h}
|
return timeHandler{h}
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ func (h timeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ValidateAuthHeaderHandler -
|
// ValidateAuthHeaderHandler -
|
||||||
// validate auth header handler is wrapper handler used for API request validation with authorization header.
|
// validate auth header handler is wrapper handler used for request validation with authorization header.
|
||||||
// Current authorization layer supports S3's standard HMAC based signature request.
|
// Current authorization layer supports S3's standard HMAC based signature request.
|
||||||
func ValidateAuthHeaderHandler(h http.Handler) http.Handler {
|
func ValidateAuthHeaderHandler(h http.Handler) http.Handler {
|
||||||
return validateAuthHandler{h}
|
return validateAuthHandler{h}
|
||||||
|
@ -18,6 +18,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -33,8 +34,23 @@ type encoder interface {
|
|||||||
|
|
||||||
//// helpers
|
//// helpers
|
||||||
|
|
||||||
|
// Static alphaNumeric table used for generating unique request ids
|
||||||
|
var alphaNumericTable = []byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||||
|
|
||||||
|
// generateRequestID generate request id
|
||||||
|
func generateRequestID() []byte {
|
||||||
|
alpha := make([]byte, 16)
|
||||||
|
rand.Read(alpha)
|
||||||
|
for i := 0; i < 16; i++ {
|
||||||
|
alpha[i] = alphaNumericTable[alpha[i]%byte(len(alphaNumericTable))]
|
||||||
|
}
|
||||||
|
return alpha
|
||||||
|
}
|
||||||
|
|
||||||
// Write http common headers
|
// Write http common headers
|
||||||
func setCommonHeaders(w http.ResponseWriter, acceptsType string, contentLength int) {
|
func setCommonHeaders(w http.ResponseWriter, acceptsType string, contentLength int) {
|
||||||
|
// set unique request ID for each reply
|
||||||
|
w.Header().Set("X-Amz-Request-Id", string(generateRequestID()))
|
||||||
w.Header().Set("Server", "Minio")
|
w.Header().Set("Server", "Minio")
|
||||||
w.Header().Set("Accept-Ranges", "bytes")
|
w.Header().Set("Accept-Ranges", "bytes")
|
||||||
w.Header().Set("Content-Type", acceptsType)
|
w.Header().Set("Content-Type", acceptsType)
|
||||||
|
Loading…
Reference in New Issue
Block a user