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

Commit

Permalink
Revert changes to GetExtCacheData() made in prebid#1104 (prebid#1130) (
Browse files Browse the repository at this point in the history
  • Loading branch information
Austinb authored and SyntaxNode committed Dec 4, 2019
1 parent 1b47f16 commit 0b192f8
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 32 deletions.
4 changes: 2 additions & 2 deletions exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,11 @@ func (e *exchange) getBidCacheInfo(bid *pbsOrtbBid, auc *auction) (openrtb_ext.E
if cacheUUID, found = auc.cacheIds[bid.bid]; found {
cacheInfo.CacheId = cacheUUID
extCacheHost, extCachePath = e.cache.GetExtCacheData()
cacheInfo.Url = extCacheHost + "/" + extCachePath + "?uuid=" + cacheUUID
cacheInfo.Url = extCacheHost + extCachePath + "?uuid=" + cacheUUID
} else if cacheUUID, found = auc.vastCacheIds[bid.bid]; found {
cacheInfo.CacheId = cacheUUID
extCacheHost, extCachePath = e.cache.GetExtCacheData()
cacheInfo.Url = extCacheHost + "/" + extCachePath + "?uuid=" + cacheUUID
cacheInfo.Url = extCacheHost + extCachePath + "?uuid=" + cacheUUID
}
}
return cacheInfo, found
Expand Down
2 changes: 1 addition & 1 deletion exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ func mockHandler(statusCode int, getBody string, postBody string) http.Handler {
type wellBehavedCache struct{}

func (c *wellBehavedCache) GetExtCacheData() (string, string) {
return "www.pbcserver.com", "pbcache/endpoint"
return "www.pbcserver.com", "/pbcache/endpoint"
}

func (c *wellBehavedCache) PutJson(ctx context.Context, values []prebid_cache_client.Cacheable) ([]string, []error) {
Expand Down
8 changes: 4 additions & 4 deletions exchange/exchangetest/include-brand-category.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
"hb_bidder_appnexus": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_pb": "0.20",
"hb_pb_appnexus": "0.20",
"hb_pb_cat_dur": "0.20_VideoGames_0s",
Expand All @@ -128,8 +128,8 @@
"hb_bidder_appnexus": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_pb": "0.50",
"hb_pb_appnexus": "0.50",
"hb_pb_cat_dur": "0.50_HomeDecor_0s",
Expand Down
4 changes: 2 additions & 2 deletions exchange/exchangetest/targeting-cache-vast-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
"hb_bidder_appnexus": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_pb": "0.00",
"hb_pb_appnexus": "0.00",
"hb_size": "200x250",
Expand Down
4 changes: 2 additions & 2 deletions exchange/exchangetest/targeting-cache-vast.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"hb_bidder_appnexus": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_uuid": "0",
"hb_uuid_appnexus": "0",
"hb_pb": "0.00",
Expand Down
4 changes: 2 additions & 2 deletions exchange/exchangetest/targeting-cache-zero.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_id": "0",
"hb_cache_id_appnexus": "0",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_uuid": "1",
"hb_uuid_appnexus": "1",
"hb_pb": "0.00",
Expand Down
10 changes: 5 additions & 5 deletions exchange/exchangetest/targeting-mobile.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"targeting": {
"hb_bidder_audienceNe": "audienceNetwork",
"hb_cache_host_audien": "www.pbcserver.com",
"hb_cache_path_audien": "pbcache/endpoint",
"hb_cache_path_audien": "/pbcache/endpoint",
"hb_pb_audienceNetwor": "0.50",
"hb_size_audienceNetw": "200x250",
"hb_env_audienceNetwo": "mobile-app"
Expand All @@ -148,8 +148,8 @@
"hb_bidder": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_bidder_appnexus": "appnexus",
"hb_pb": "0.70",
"hb_pb_appnexus": "0.70",
Expand Down Expand Up @@ -188,8 +188,8 @@
"hb_bidder": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_bidder_appnexus": "appnexus",
"hb_pb": "0.60",
"hb_pb_appnexus": "0.60",
Expand Down
6 changes: 3 additions & 3 deletions exchange/exchangetest/targeting-no-winners.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"targeting": {
"hb_bidder_audienceNe": "audienceNetwork",
"hb_cache_host_audien": "www.pbcserver.com",
"hb_cache_path_audien": "pbcache/endpoint",
"hb_cache_path_audien": "/pbcache/endpoint",
"hb_pb_audienceNetwor": "0.50",
"hb_size_audienceNetw": "200x250"
}
Expand All @@ -148,7 +148,7 @@
"targeting": {
"hb_bidder_appnexus": "appnexus",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_pb_appnexus": "0.70",
"hb_size_appnexus": "200x250"
}
Expand Down Expand Up @@ -181,7 +181,7 @@
"targeting": {
"hb_bidder_appnexus": "appnexus",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_pb_appnexus": "0.60",
"hb_size_appnexus": "300x500"
}
Expand Down
4 changes: 2 additions & 2 deletions exchange/exchangetest/targeting-only-winners.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"targeting": {
"hb_bidder": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_pb": "0.70",
"hb_size": "200x250"
}
Expand Down Expand Up @@ -174,7 +174,7 @@
"targeting": {
"hb_bidder": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_pb": "0.60",
"hb_size": "300x500"
}
Expand Down
10 changes: 5 additions & 5 deletions exchange/exchangetest/targeting-with-winners.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"targeting": {
"hb_bidder_audienceNe": "audienceNetwork",
"hb_cache_host_audien": "www.pbcserver.com",
"hb_cache_path_audien": "pbcache/endpoint",
"hb_cache_path_audien": "/pbcache/endpoint",
"hb_pb_audienceNetwor": "0.50",
"hb_size_audienceNetw": "200x250"
}
Expand All @@ -148,8 +148,8 @@
"hb_bidder_appnexus": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_pb": "0.70",
"hb_pb_appnexus": "0.70",
"hb_size": "200x250",
Expand Down Expand Up @@ -186,8 +186,8 @@
"hb_bidder_appnexus": "appnexus",
"hb_cache_host": "www.pbcserver.com",
"hb_cache_host_appnex": "www.pbcserver.com",
"hb_cache_path": "pbcache/endpoint",
"hb_cache_path_appnex": "pbcache/endpoint",
"hb_cache_path": "/pbcache/endpoint",
"hb_cache_path_appnex": "/pbcache/endpoint",
"hb_pb": "0.60",
"hb_pb_appnexus": "0.60",
"hb_size": "300x500",
Expand Down
6 changes: 4 additions & 2 deletions prebid_cache_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ type clientImpl struct {
func (c *clientImpl) GetExtCacheData() (string, string) {
path := c.externalCachePath
if path == "/" {
// Only the slash for the path, remove it to empty
path = ""
} else if strings.Index(path, "/") == 0 {
path = strings.TrimLeft(path, "/")
} else if len(path) > 0 && !strings.HasPrefix(path, "/") {
// Path defined but does not start with "/", prepend it
path = "/" + path
}

return c.externalCacheHost, path
Expand Down
20 changes: 18 additions & 2 deletions prebid_cache_client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ func TestStripCacheHostAndPath(t *testing.T) {
{
inExtCacheURL: config.ExternalCache{
Host: "prebid-server.prebid.org",
Path: "pbcache/endpoint",
Path: "/pbcache/endpoint",
},
expectedHost: "prebid-server.prebid.org",
expectedPath: "pbcache/endpoint",
expectedPath: "/pbcache/endpoint",
},
{
inExtCacheURL: config.ExternalCache{
Expand All @@ -177,6 +177,22 @@ func TestStripCacheHostAndPath(t *testing.T) {
expectedHost: "",
expectedPath: "",
},
{
inExtCacheURL: config.ExternalCache{
Host: "prebid-server.prebid.org",
Path: "pbcache/endpoint",
},
expectedHost: "prebid-server.prebid.org",
expectedPath: "/pbcache/endpoint",
},
{
inExtCacheURL: config.ExternalCache{
Host: "prebidcache.net",
Path: "/",
},
expectedHost: "prebidcache.net",
expectedPath: "",
},
}
for _, test := range testInput {
//start client
Expand Down

0 comments on commit 0b192f8

Please sign in to comment.