From cfd490870d4df6f49e509f5cd9b1f67f341bc28c Mon Sep 17 00:00:00 2001 From: rahulmadathumpalliyalil Date: Wed, 16 Feb 2022 16:25:20 +0000 Subject: [PATCH] test --- http/client.go | 15 ++++++++++++--- http/custom_roundtripper.go | 7 ++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/http/client.go b/http/client.go index 8c77367..97e7969 100644 --- a/http/client.go +++ b/http/client.go @@ -12,7 +12,7 @@ import ( "strings" "time" - request "github.com/ONSdigital/dp-net/request" + "github.com/ONSdigital/dp-net/request" "golang.org/x/net/context" "golang.org/x/net/context/ctxhttp" ) @@ -68,8 +68,16 @@ type Clienter interface { // NewClient returns a copy of DefaultClient. func NewClient() Clienter { - newClient := *DefaultClient - return &newClient + newClient := &Client{ + MaxRetries: 3, + RetryTime: 20 * time.Millisecond, + + HTTPClient: &http.Client{ + Timeout: 10 * time.Second, + Transport: DefaultTransport, + }, + } + return newClient } // NewClientWithAwsSigner return a new client with aws signer profile. @@ -94,6 +102,7 @@ func ClientWithTimeout(c Clienter, timeout time.Duration) Clienter { // Clienter roundtripper calls the httpclient roundtripper. func (c *Client) RoundTrip(req *http.Request) (*http.Response, error) { + req.Header.Set("test", "001") return c.HTTPClient.Transport.RoundTrip(req) } diff --git a/http/custom_roundtripper.go b/http/custom_roundtripper.go index 95082d9..54b7f46 100644 --- a/http/custom_roundtripper.go +++ b/http/custom_roundtripper.go @@ -3,11 +3,10 @@ package http import ( "bytes" "fmt" + awsAuth "github.com/ONSdigital/dp-net/awsauth" "io" "net/http" "time" - - awsAuth "github.com/ONSdigital/dp-net/awsauth" ) type AwsSignerRoundTripper struct { @@ -16,6 +15,7 @@ type AwsSignerRoundTripper struct { } func NewAWSSignerRoundTripper(awsFilename, awsProfile, awsRegion, awsService string, customTransport http.RoundTripper) (*AwsSignerRoundTripper, error) { + fmt.Println("inside aws signer..........................") var roundTripper http.RoundTripper if awsRegion == "" || awsService == "" { return nil, fmt.Errorf("aws region and service should be valid options") @@ -32,12 +32,13 @@ func NewAWSSignerRoundTripper(awsFilename, awsProfile, awsRegion, awsService str } return &AwsSignerRoundTripper{ - signer: awsSigner, roundTripper: roundTripper, + signer: awsSigner, }, nil } func (srt *AwsSignerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + fmt.Println("inside round tripper..........................") var body []byte var err error if req.Body != nil {