Skip to content

Commit

Permalink
Fixed a bug related to Content Disposition parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanjain28 committed Sep 11, 2017
1 parent c528769 commit 6c89b3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE=pluto
VERSION=1.4
VERSION=1.4.1

ARCH_LINUX = $(PACKAGE)-$(VERSION)-linux-amd64 \
$(PACKAGE)-$(VERSION)-linux-arm64 \
Expand Down
19 changes: 12 additions & 7 deletions pluto/pluto.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package pluto provides a way to download files at high speeds by using http ranged requests.
package pluto

import (
Expand Down Expand Up @@ -224,15 +225,19 @@ func FetchMeta(u *url.URL) (*FileMeta, error) {
return nil, fmt.Errorf("error in sending GET request: %v", err)
}

cDispose := strings.Split(resp.Header.Get("Content-Disposition"), "filename=")

name := ""

if len(cDispose) > 0 {
cdfilename := cDispose[1]
cdfilename = cdfilename[1:]
cdfilename = cdfilename[:len(cdfilename)-1]
name = cdfilename
dispositionHeader := resp.Header.Get("Content-Disposition")

if dispositionHeader != "" {
cDispose := strings.Split(dispositionHeader, "filename=")

if len(cDispose) > 0 {
cdfilename := cDispose[1]
cdfilename = cdfilename[1:]
cdfilename = cdfilename[:len(cdfilename)-1]
name = cdfilename
}
}

resp.Body.Close()
Expand Down

0 comments on commit 6c89b3a

Please sign in to comment.