@Override public Collection<Part> getParts() { return target.getParts(); }
private MatchResult matchAllMultiparts(final Request request) { return from(request.getParts()).allMatch(new Predicate<Request.Part>() { @Override public boolean apply(Request.Part input) { return MultipartValuePattern.this.match(input).isExactMatch(); } }) ? MatchResult.exactMatch() : MatchResult.noMatch(); }
private MatchResult matchAnyMultipart(final Request request) { Collection<Request.Part> parts = request.getParts(); if (parts == null || parts.isEmpty()) { return MatchResult.noMatch(); } return from(parts).anyMatch(new Predicate<Request.Part>() { @Override public boolean apply(Request.Part input) { return MultipartValuePattern.this.match(input).isExactMatch(); } }) ? MatchResult.exactMatch() : MatchResult.noMatch(); }
public static LoggedRequest createFrom(Request request) { return new LoggedRequest(request.getUrl(), request.getAbsoluteUrl(), request.getMethod(), request.getClientIp(), copyOf(request.getHeaders()), ImmutableMap.copyOf(request.getCookies()), request.isBrowserProxyRequest(), new Date(), request.getBody(), request.getParts() ); }
builder.add(new SectionDelimiter("[Multipart request body]", "")); } else if (!pattern.match(request).isExactMatch()) { for (Request.Part part: request.getParts()) { builder.add(SPACER); String patternPartName = pattern.getName() == null ? "" : ": " + pattern.getName();
private RequestPattern buildRequestPatternFrom(Request request) { RequestPatternBuilder builder = newRequestPattern(request.getMethod(), urlEqualTo(request.getUrl())); if (!headersToMatch.isEmpty()) { for (HttpHeader header: request.getHeaders().all()) { if (headersToMatch.contains(header.caseInsensitiveKey())) { builder.withHeader(header.key(), equalTo(header.firstValue())); } } } if (request.isMultipart()) { for (Request.Part part : request.getParts()) { builder.withRequestBodyPart(valuePatternForPart(part)); } } else { String body = request.getBodyAsString(); if (!body.isEmpty()) { builder.withRequestBody(valuePatternForContentType(request)); } } return builder.build(); }