|
|
@ -77,6 +77,8 @@ func CheckAcceptMediaType(ctx *context.Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rangeHeaderRegexp = regexp.MustCompile(`bytes=(\d+)\-(\d*).*`)
|
|
|
|
|
|
|
|
|
|
|
|
// DownloadHandler gets the content from the content store
|
|
|
|
// DownloadHandler gets the content from the content store
|
|
|
|
func DownloadHandler(ctx *context.Context) {
|
|
|
|
func DownloadHandler(ctx *context.Context) {
|
|
|
|
rc := getRequestContext(ctx)
|
|
|
|
rc := getRequestContext(ctx)
|
|
|
@ -92,8 +94,7 @@ func DownloadHandler(ctx *context.Context) {
|
|
|
|
toByte = meta.Size - 1
|
|
|
|
toByte = meta.Size - 1
|
|
|
|
statusCode := http.StatusOK
|
|
|
|
statusCode := http.StatusOK
|
|
|
|
if rangeHdr := ctx.Req.Header.Get("Range"); rangeHdr != "" {
|
|
|
|
if rangeHdr := ctx.Req.Header.Get("Range"); rangeHdr != "" {
|
|
|
|
regex := regexp.MustCompile(`bytes=(\d+)\-(\d*).*`)
|
|
|
|
match := rangeHeaderRegexp.FindStringSubmatch(rangeHdr)
|
|
|
|
match := regex.FindStringSubmatch(rangeHdr)
|
|
|
|
|
|
|
|
if len(match) > 1 {
|
|
|
|
if len(match) > 1 {
|
|
|
|
statusCode = http.StatusPartialContent
|
|
|
|
statusCode = http.StatusPartialContent
|
|
|
|
fromByte, _ = strconv.ParseInt(match[1], 10, 32)
|
|
|
|
fromByte, _ = strconv.ParseInt(match[1], 10, 32)
|
|
|
|