Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Removed some redundant methods (prebid#1320)
Browse files Browse the repository at this point in the history
* TELARIA adapter. First Pass

* Some refactoring

* added the json files

* fixed some tests and added the bidder info

* fixed some tests and added the bidder info

* added default user sync ur;

* - Handling gzipped responses from our server

* - more refactoring.

* added the proper user sync default URL

* changed the urls from dev to prod

* changed up the required fields. Now AdCode in the Imp.Ext isn't required but Bid.SeatCode is required

* change in the return type after decompressing

* some refactoring

* change in our config url

* using pbs.yml to switch between our production and test URLs

* setting default endpoint

* - fixed the issue that was preventing telaria test cases to run.
- added more test cases

* - Modifications as per the changes requested by the maintainers.

* Moved the seat code to imp.ext

* Moved the seat code to imp.ext

* Added 'Telaria: ' prefix for error messages

* - Fixes for race conditions. Was modifying the original request object instead of a copy

* cosmetic changes.

* added params_test.go

* Removed some redundant methods.

* Removed a comment

Co-authored-by: Vinay Prasad <[email protected]>
  • Loading branch information
telariaEng and Vinay Prasad authored Jun 2, 2020
1 parent d5391b2 commit 5b7d23c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 39 deletions.
37 changes: 1 addition & 36 deletions adapters/telaria/telaria.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package telaria

import (
"bytes"
"compress/gzip"
"encoding/json"
"fmt"
"github.com/mxmCherry/openrtb"
Expand Down Expand Up @@ -79,7 +77,6 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header {
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
headers.Add("X-Openrtb-Version", "2.5")
headers.Add("Accept-Encoding", "gzip")

if request.Device != nil {
if len(request.Device.UA) > 0 {
Expand Down Expand Up @@ -233,34 +230,6 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad
}}, nil
}

// response isn't automatically decompressed. This method unzips the response if Content-Encoding is gzip
func GetResponseBody(response *adapters.ResponseData) ([]byte, error) {

if "gzip" == response.Headers.Get("Content-Encoding") {
body := bytes.NewBuffer(response.Body)
r, readerErr := gzip.NewReader(body)
if readerErr != nil {
return nil, &errortypes.BadServerResponse{
Message: fmt.Sprintf("Error while trying to unzip data [ %d ]", response.StatusCode),
}
}
var resB bytes.Buffer
var err error
_, err = resB.ReadFrom(r)
if err != nil {
return nil, &errortypes.BadServerResponse{
Message: fmt.Sprintf("Error while trying to unzip data [ %d ]", response.StatusCode),
}
}

response.Headers.Del("Content-Encoding")

return resB.Bytes(), nil
} else {
return response.Body, nil
}
}

func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseData) error {
if response.StatusCode == http.StatusNoContent {
return &errortypes.BadInput{Message: "Telaria: Invalid Bid Request received by the server"}
Expand Down Expand Up @@ -294,11 +263,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR
return nil, []error{httpStatusError}
}

responseBody, err := GetResponseBody(response)

if err != nil {
return nil, []error{err}
}
responseBody := response.Body

var bidResp openrtb.BidResponse
if err := json.Unmarshal(responseBody, &bidResp); err != nil {
Expand Down
1 change: 0 additions & 1 deletion adapters/telaria/telariatest/exemplary/video-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"Content-Type": ["application/json;charset=utf-8"],
"Accept": ["application/json"],
"X-Openrtb-Version": ["2.5"],
"Accept-Encoding": ["gzip"],
"User-Agent": ["test-user-agent"],
"X-Forwarded-For": ["123.123.123.123"],
"Accept-Language": ["en"],
Expand Down
1 change: 0 additions & 1 deletion adapters/telaria/telariatest/exemplary/video-web.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"Content-Type": ["application/json;charset=utf-8"],
"Accept": ["application/json"],
"X-Openrtb-Version": ["2.5"],
"Accept-Encoding": ["gzip"],
"User-Agent": ["test-user-agent"],
"X-Forwarded-For": ["123.123.123.123"],
"Accept-Language": ["en"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"Content-Type": ["application/json;charset=utf-8"],
"Accept": ["application/json"],
"X-Openrtb-Version": ["2.5"],
"Accept-Encoding": ["gzip"],
"User-Agent": ["test-user-agent"],
"X-Forwarded-For": ["123.123.123.123"],
"Accept-Language": ["en"],
Expand Down

0 comments on commit 5b7d23c

Please sign in to comment.