@ -175,6 +175,11 @@ func getContentHandler(ctx *context.Context) {
statusCode = 206
statusCode = 206
fromByte , _ = strconv . ParseInt ( match [ 1 ] , 10 , 32 )
fromByte , _ = strconv . ParseInt ( match [ 1 ] , 10 , 32 )
if fromByte >= meta . Size {
writeStatus ( ctx , http . StatusRequestedRangeNotSatisfiable )
return
}
if match [ 2 ] != "" {
if match [ 2 ] != "" {
_toByte , _ := strconv . ParseInt ( match [ 2 ] , 10 , 32 )
_toByte , _ := strconv . ParseInt ( match [ 2 ] , 10 , 32 )
if _toByte >= fromByte && _toByte < toByte {
if _toByte >= fromByte && _toByte < toByte {
@ -188,18 +193,24 @@ func getContentHandler(ctx *context.Context) {
}
}
contentStore := & ContentStore { ObjectStorage : storage . LFS }
contentStore := & ContentStore { ObjectStorage : storage . LFS }
content , err := contentStore . Get ( meta , fromByte )
content , err := contentStore . Get ( meta )
if err != nil {
if err != nil {
if IsErrRangeNotSatisfiable ( err ) {
writeStatus ( ctx , http . StatusRequestedRangeNotSatisfiable )
} else {
// Errors are logged in contentStore.Get
// Errors are logged in contentStore.Get
writeStatus ( ctx , 404 )
writeStatus ( ctx , http . StatusNotFound )
}
return
return
}
}
defer content . Close ( )
defer content . Close ( )
if fromByte > 0 {
_ , err = content . Seek ( fromByte , io . SeekStart )
if err != nil {
log . Error ( "Whilst trying to read LFS OID[%s]: Unable to seek to %d Error: %v" , meta . Oid , fromByte , err )
writeStatus ( ctx , http . StatusInternalServerError )
return
}
}
contentLength := toByte + 1 - fromByte
contentLength := toByte + 1 - fromByte
ctx . Resp . Header ( ) . Set ( "Content-Length" , strconv . FormatInt ( contentLength , 10 ) )
ctx . Resp . Header ( ) . Set ( "Content-Length" , strconv . FormatInt ( contentLength , 10 ) )
ctx . Resp . Header ( ) . Set ( "Content-Type" , "application/octet-stream" )
ctx . Resp . Header ( ) . Set ( "Content-Type" , "application/octet-stream" )