Skip to content

Commit

Permalink
Allow preserving cookies for proxies (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored and kannappanr committed Jan 2, 2019
1 parent d917552 commit 5f40a0c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api.go
Expand Up @@ -30,6 +30,7 @@ import (
"math/rand"
"net"
"net/http"
"net/http/cookiejar"
"net/http/httputil"
"net/url"
"os"
Expand All @@ -38,6 +39,8 @@ import (
"sync"
"time"

"golang.org/x/net/publicsuffix"

"github.com/minio/minio-go/pkg/credentials"
"github.com/minio/minio-go/pkg/s3signer"
"github.com/minio/minio-go/pkg/s3utils"
Expand Down Expand Up @@ -273,6 +276,13 @@ func privateNew(endpoint string, creds *credentials.Credentials, secure bool, re
return nil, err
}

// Initialize cookies to preserve server sent cookies if any and replay
// them upon each request.
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
if err != nil {
return nil, err
}

// instantiate new Client.
clnt := new(Client)

Expand All @@ -287,6 +297,7 @@ func privateNew(endpoint string, creds *credentials.Credentials, secure bool, re

// Instantiate http client and bucket location cache.
clnt.httpClient = &http.Client{
Jar: jar,
Transport: DefaultTransport,
CheckRedirect: clnt.redirectHeaders,
}
Expand Down

0 comments on commit 5f40a0c

Please sign in to comment.