in shadows/httpclient/src/main/java/org/robolectric/shadows/httpclient/FakeHttpLayer.java [408:451]
public boolean matches(HttpRequest request) {
URI uri = URI.create(request.getRequestLine().getUri());
if (method != null && !method.equals(request.getRequestLine().getMethod())) {
return false;
}
if (hostname != null && !hostname.equals(uri.getHost())) {
return false;
}
if (path != null && !path.equals(uri.getRawPath())) {
return false;
}
if (noParams && !uri.getRawQuery().equals(null)) {
return false;
}
if (params.size() > 0) {
Map<String, String> requestParams = ParamsParser.parseParams(request);
if (!requestParams.equals(params)) {
return false;
}
}
if (headers.size() > 0) {
Map<String, String> actualRequestHeaders = new HashMap<>();
for (Header header : request.getAllHeaders()) {
actualRequestHeaders.put(header.getName(), header.getValue());
}
if (!headers.equals(actualRequestHeaders)) {
return false;
}
}
if (postBodyMatcher != null) {
if (!(request instanceof HttpEntityEnclosingRequestBase)) {
return false;
}
HttpEntityEnclosingRequestBase postOrPut = (HttpEntityEnclosingRequestBase) request;
try {
if (!postBodyMatcher.matches(postOrPut.getEntity())) {
return false;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return true;
}