Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private ExtDevice updateExt(ExtDevice ortbExtDevice) {
}

private ExtDevice copyExtDevice(ExtDevice original) {
final ExtDevice copy = ExtDevice.of(original.getAtts(), original.getPrebid());
final ExtDevice copy = ExtDevice.of(original.getAtts(), original.getIfaType(), original.getPrebid());
mapper.fillExtension(copy, original);
return copy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void callShouldReturnNoActionWhenDeviceHasWurflProperty() {
// given
final String ua = "Mozilla/5.0 (testPhone; CPU testPhone OS 1_0_2) Version/17.4.1 Mobile/12E GrandTest/604.1";
final ExtDevicePrebid extDevicePrebid = ExtDevicePrebid.of(ExtDeviceInt.of(80, 80));
final ExtDevice extDevice = ExtDevice.of(0, extDevicePrebid);
final ExtDevice extDevice = ExtDevice.of(0, null, extDevicePrebid);
final ObjectNode wurfl = mapper.mapper().createObjectNode();
wurfl.put("wurfl_id", "test_phone_ver1");
extDevice.addProperty("wurfl", wurfl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;

/**
Expand Down Expand Up @@ -72,12 +73,13 @@ public List<String> ipFrom(MultiMap headers, String host) {

private List<String> ipFrom(Function<String, String> headerGetter, String host) {
final List<String> candidates = new ArrayList<>();
candidates.add(headerGetter.apply("True-Client-IP"));
final String xff = headerGetter.apply("X-Forwarded-For");
candidates.add(headerGetter.apply(HttpUtil.TRUE_CLIENT_IP_HEADER.toString()));
final String xff = headerGetter.apply(HttpUtil.X_FORWARDED_FOR_HEADER.toString());
if (xff != null) {
candidates.addAll(Arrays.asList(xff.split(",")));
}
candidates.add(headerGetter.apply("X-Real-IP"));
candidates.add(headerGetter.apply(HttpUtil.X_REAL_IP_HEADER.toString()));
candidates.add(headerGetter.apply(HttpUtil.X_DEVICE_IP_HEADER.toString()));
candidates.add(host);

return candidates.stream()
Expand All @@ -90,7 +92,12 @@ private List<String> ipFrom(Function<String, String> headerGetter, String host)
* Determines User-Agent by checking 'User-Agent' http header.
*/
public String uaFrom(HttpRequestContext request) {
return StringUtils.trimToNull(request.getHeaders().get(HttpUtil.USER_AGENT_HEADER));
return Optional.ofNullable(getTrimmedHeader(request, HttpUtil.USER_AGENT_HEADER))
.orElseGet(() -> getTrimmedHeader(request, HttpUtil.X_DEVICE_USER_AGENT_HEADER));
}

private static String getTrimmedHeader(HttpRequestContext request, CharSequence header) {
return StringUtils.trimToNull(request.getHeaders().get(header));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private BidRequest fillExplicitParameters(BidRequest bidRequest, Account account
*/
private BidRequest overrideParameters(BidRequest bidRequest, HttpRequestContext httpRequest, List<String> errors) {
final String requestTargeting = httpRequest.getQueryParams().get(TARGETING_REQUEST_PARAM);
final ObjectNode targetingNode = readTargeting(requestTargeting);
final ObjectNode targetingNode = readTargeting(requestTargeting, mapper);
final String referer = implicitParametersExtractor.refererFrom(httpRequest);
ortbTypesResolver.normalizeTargeting(targetingNode, errors, referer);

Expand All @@ -542,7 +542,7 @@ private BidRequest overrideParameters(BidRequest bidRequest, HttpRequestContext
return bidRequest;
}

private ObjectNode readTargeting(String jsonTargeting) {
public static ObjectNode readTargeting(String jsonTargeting, JacksonMapper mapper) {
try {
final String decodedJsonTargeting = HttpUtil.decodeUrl(jsonTargeting);
final JsonNode jsonNodeTargeting = decodedJsonTargeting != null
Expand All @@ -554,7 +554,7 @@ private ObjectNode readTargeting(String jsonTargeting) {
}
}

private ObjectNode validateAndGetTargeting(JsonNode jsonNodeTargeting) {
private static ObjectNode validateAndGetTargeting(JsonNode jsonNodeTargeting) {
if (jsonNodeTargeting.isObject()) {
return (ObjectNode) jsonNodeTargeting;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
*/
public class AuctionRequestFactory {

private static final String ENDPOINT = Endpoint.openrtb2_auction.value();

private final long maxRequestSize;
private final Ortb2RequestFactory ortb2RequestFactory;
private final StoredRequestProcessor storedRequestProcessor;
Expand All @@ -55,8 +57,6 @@ public class AuctionRequestFactory {
private final GeoLocationServiceWrapper geoLocationServiceWrapper;
private final BidAdjustmentsEnricher bidAdjustmentsEnricher;

private static final String ENDPOINT = Endpoint.openrtb2_auction.value();

public AuctionRequestFactory(long maxRequestSize,
Ortb2RequestFactory ortb2RequestFactory,
StoredRequestProcessor storedRequestProcessor,
Expand Down
Loading
Loading