mirror of
https://github.com/minio/minio.git
synced 2024-12-25 06:35:56 -05:00
Rename writeObjectHeaders to setObjectHeaders, fix writing multiple headers bug
This commit is contained in:
parent
6fd78dba42
commit
d644233054
@ -52,14 +52,10 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
|
|||||||
}
|
}
|
||||||
switch httpRange.start == 0 && httpRange.length == 0 {
|
switch httpRange.start == 0 && httpRange.length == 0 {
|
||||||
case true:
|
case true:
|
||||||
writeObjectHeaders(w, metadata)
|
setObjectHeaders(w, metadata)
|
||||||
if _, err := server.driver.GetObject(w, bucket, object); err != nil {
|
if _, err := server.driver.GetObject(w, bucket, object); err != nil {
|
||||||
log.Error.Println(err)
|
log.Error.Println(err)
|
||||||
error := getErrorCode(InternalError)
|
// unable to write headers, we've already printed data. Just close the connection.
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
|
||||||
w.Write(encodeErrorResponse(errorResponse, acceptsContentType))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case false:
|
case false:
|
||||||
@ -69,11 +65,7 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
|
|||||||
_, err := server.driver.GetPartialObject(w, bucket, object, httpRange.start, httpRange.length)
|
_, err := server.driver.GetPartialObject(w, bucket, object, httpRange.start, httpRange.length)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error.Println(err)
|
log.Error.Println(err)
|
||||||
error := getErrorCode(InternalError)
|
// unable to write headers, we've already printed data. Just close the connection.
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
|
||||||
w.Write(encodeErrorResponse(errorResponse, acceptsContentType))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +129,7 @@ func (server *minioAPI) headObjectHandler(w http.ResponseWriter, req *http.Reque
|
|||||||
metadata, err := server.driver.GetObjectMetadata(bucket, object, "")
|
metadata, err := server.driver.GetObjectMetadata(bucket, object, "")
|
||||||
switch err := err.(type) {
|
switch err := err.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
writeObjectHeaders(w, metadata)
|
setObjectHeaders(w, metadata)
|
||||||
case drivers.ObjectNotFound:
|
case drivers.ObjectNotFound:
|
||||||
{
|
{
|
||||||
error := getErrorCode(NoSuchKey)
|
error := getErrorCode(NoSuchKey)
|
||||||
|
@ -58,7 +58,7 @@ func encodeErrorResponse(response interface{}, acceptsType contentType) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write object header
|
// Write object header
|
||||||
func writeObjectHeaders(w http.ResponseWriter, metadata drivers.ObjectMetadata) {
|
func setObjectHeaders(w http.ResponseWriter, metadata drivers.ObjectMetadata) {
|
||||||
lastModified := metadata.Created.Format(time.RFC1123)
|
lastModified := metadata.Created.Format(time.RFC1123)
|
||||||
// common headers
|
// common headers
|
||||||
setCommonHeaders(w, metadata.ContentType)
|
setCommonHeaders(w, metadata.ContentType)
|
||||||
|
Loading…
Reference in New Issue
Block a user