Class ResponsePredicate
- All Implemented Interfaces:
MutinyDelegate,Function<HttpResponse<Void>,ResponsePredicateResult>
By default, a Vert.x Web Client request ends with an error only if something wrong happens at the network level.
In other words, a 404 Not Found response, or a response with the wrong content type, are NOT considered as failures.
Response predicates can fail a request when the response does not match some criteria.
Custom predicate instances can be used with .
As a convenience, a few predicates for common uses cases are predefined. For example:
ResponsePredicateto verify that the response has a2xxcode, orResponsePredicateto verify that the response body contains JSON data.- ...
However, you can create a new ResponsePredicate instance from an existing one using create(java.util.function.Function<io.vertx.mutiny.ext.web.client.HttpResponse<java.lang.Void>, io.vertx.mutiny.ext.web.client.predicate.ResponsePredicateResult>) or
create(java.util.function.Function<io.vertx.mutiny.ext.web.client.HttpResponse<java.lang.Void>, io.vertx.mutiny.ext.web.client.predicate.ResponsePredicateResult>) when the body is required to build the validation failure.
original non Mutiny-ified interface using Vert.x codegen.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TypeArg<ResponsePredicate>static final ResponsePredicateCreates a predicate validating the responsecontent-typeisapplication/json.static final ResponsePredicate202 Acceptedstatic final ResponsePredicate502 Bad Gatewaystatic final ResponsePredicate400 Bad Requeststatic final ResponsePredicateAny 4XX client errorstatic final ResponsePredicate409 Conflictstatic final ResponsePredicate100 Continuestatic final ResponsePredicate201 Createdstatic final ResponsePredicate103 Early Hintsstatic final ResponsePredicate417 Expectation Failedstatic final ResponsePredicate424 Failed Dependency (WebDAV, RFC4918)static final ResponsePredicate403 Forbiddenstatic final ResponsePredicate302 Foundstatic final ResponsePredicate504 Gateway Timeoutstatic final ResponsePredicate410 Gonestatic final ResponsePredicate505 HTTP Version Not Supportedstatic final ResponsePredicateAny 1XX informational responsestatic final ResponsePredicate507 Insufficient Storage (WebDAV, RFC4918)static final ResponsePredicate500 Internal Server Errorstatic final ResponsePredicate411 Length Requiredstatic final ResponsePredicate423 Locked (WebDAV, RFC4918)static final ResponsePredicate405 Method Not Allowedstatic final ResponsePredicate421 Misdirected Requeststatic final ResponsePredicate301 Moved Permanentlystatic final ResponsePredicate207 Multi-Status (WebDAV, RFC2518)static final ResponsePredicate300 Multiple Choicesstatic final ResponsePredicate511 Network Authentication Required (RFC6585)static final ResponsePredicate204 No Contentstatic final ResponsePredicate203 Non-Authoritative Information (since HTTP/1.1)static final ResponsePredicate406 Not Acceptablestatic final ResponsePredicate510 Not Extended (RFC2774)static final ResponsePredicate404 Not Foundstatic final ResponsePredicate501 Not Implementedstatic final ResponsePredicate304 Not Modifiedstatic final ResponsePredicate200 OKstatic final ResponsePredicate206 Partial Contentstatic final ResponsePredicate402 Payment Requiredstatic final ResponsePredicate308 Permanent Redirect (RFC7538)static final ResponsePredicate412 Precondition Failedstatic final ResponsePredicate428 Precondition Required (RFC6585)static final ResponsePredicate102 Processing (WebDAV, RFC2518)static final ResponsePredicate407 Proxy Authentication Requiredstatic final ResponsePredicateAny 3XX redirectionstatic final ResponsePredicate413 Request Entity Too Largestatic final ResponsePredicate431 Request Header Fields Too Large (RFC6585)static final ResponsePredicate408 Request Timeoutstatic final ResponsePredicate414 Request-URI Too Longstatic final ResponsePredicate416 Requested Range Not Satisfiablestatic final ResponsePredicate205 Reset Contentstatic final ResponsePredicate303 See Other (since HTTP/1.1)static final ResponsePredicateAny 5XX server errorstatic final ResponsePredicate503 Service Unavailablestatic final ResponsePredicateAny 2XX successstatic final ResponsePredicate101 Switching Protocolsstatic final ResponsePredicate307 Temporary Redirect (since HTTP/1.1)static final ResponsePredicate429 Too Many Requests (RFC6585)static final ResponsePredicate401 Unauthorizedstatic final ResponsePredicate425 Unordered Collection (WebDAV, RFC3648)static final ResponsePredicate422 Unprocessable Entity (WebDAV, RFC4918)static final ResponsePredicate415 Unsupported Media Typestatic final ResponsePredicate426 Upgrade Required (RFC2817)static final ResponsePredicate305 Use Proxy (since HTTP/1.1)static final ResponsePredicate506 Variant Also Negotiates (RFC2295) -
Constructor Summary
ConstructorsConstructorDescriptionResponsePredicate(io.vertx.ext.web.client.predicate.ResponsePredicate delegate) ResponsePredicate(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionapply(HttpResponse<Void> in) static ResponsePredicatecontentType(String mimeType) Deprecated.static ResponsePredicatecontentType(List<String> mimeTypes) Deprecated.static ResponsePredicateDeprecated.static ResponsePredicatecreate(Function<HttpResponse<Void>, ResponsePredicateResult> test, ErrorConverter errorConverter) Deprecated.booleanDeprecated.io.vertx.ext.web.client.predicate.ResponsePredicateinthashCode()static ResponsePredicatenewInstance(io.vertx.ext.web.client.predicate.ResponsePredicate arg) static ResponsePredicatestatus(int statusCode) Deprecated.static ResponsePredicatestatus(int min, int max) Deprecated.toString()
-
Field Details
-
__TYPE_ARG
-
SC_INFORMATIONAL_RESPONSE
Any 1XX informational response -
SC_CONTINUE
100 Continue -
SC_SWITCHING_PROTOCOLS
101 Switching Protocols -
SC_PROCESSING
102 Processing (WebDAV, RFC2518) -
SC_EARLY_HINTS
103 Early Hints -
SC_SUCCESS
Any 2XX success -
SC_OK
200 OK -
SC_CREATED
201 Created -
SC_ACCEPTED
202 Accepted -
SC_NON_AUTHORITATIVE_INFORMATION
203 Non-Authoritative Information (since HTTP/1.1) -
SC_NO_CONTENT
204 No Content -
SC_RESET_CONTENT
205 Reset Content -
SC_PARTIAL_CONTENT
206 Partial Content -
SC_MULTI_STATUS
207 Multi-Status (WebDAV, RFC2518) -
SC_REDIRECTION
Any 3XX redirection -
SC_MULTIPLE_CHOICES
300 Multiple Choices -
SC_MOVED_PERMANENTLY
301 Moved Permanently -
SC_FOUND
302 Found -
SC_SEE_OTHER
303 See Other (since HTTP/1.1) -
SC_NOT_MODIFIED
304 Not Modified -
SC_USE_PROXY
305 Use Proxy (since HTTP/1.1) -
SC_TEMPORARY_REDIRECT
307 Temporary Redirect (since HTTP/1.1) -
SC_PERMANENT_REDIRECT
308 Permanent Redirect (RFC7538) -
SC_CLIENT_ERRORS
Any 4XX client error -
SC_BAD_REQUEST
400 Bad Request -
SC_UNAUTHORIZED
401 Unauthorized -
SC_PAYMENT_REQUIRED
402 Payment Required -
SC_FORBIDDEN
403 Forbidden -
SC_NOT_FOUND
404 Not Found -
SC_METHOD_NOT_ALLOWED
405 Method Not Allowed -
SC_NOT_ACCEPTABLE
406 Not Acceptable -
SC_PROXY_AUTHENTICATION_REQUIRED
407 Proxy Authentication Required -
SC_REQUEST_TIMEOUT
408 Request Timeout -
SC_CONFLICT
409 Conflict -
SC_GONE
410 Gone -
SC_LENGTH_REQUIRED
411 Length Required -
SC_PRECONDITION_FAILED
412 Precondition Failed -
SC_REQUEST_ENTITY_TOO_LARGE
413 Request Entity Too Large -
SC_REQUEST_URI_TOO_LONG
414 Request-URI Too Long -
SC_UNSUPPORTED_MEDIA_TYPE
415 Unsupported Media Type -
SC_REQUESTED_RANGE_NOT_SATISFIABLE
416 Requested Range Not Satisfiable -
SC_EXPECTATION_FAILED
417 Expectation Failed -
SC_MISDIRECTED_REQUEST
421 Misdirected Request -
SC_UNPROCESSABLE_ENTITY
422 Unprocessable Entity (WebDAV, RFC4918) -
SC_LOCKED
423 Locked (WebDAV, RFC4918) -
SC_FAILED_DEPENDENCY
424 Failed Dependency (WebDAV, RFC4918) -
SC_UNORDERED_COLLECTION
425 Unordered Collection (WebDAV, RFC3648) -
SC_UPGRADE_REQUIRED
426 Upgrade Required (RFC2817) -
SC_PRECONDITION_REQUIRED
428 Precondition Required (RFC6585) -
SC_TOO_MANY_REQUESTS
429 Too Many Requests (RFC6585) -
SC_REQUEST_HEADER_FIELDS_TOO_LARGE
431 Request Header Fields Too Large (RFC6585) -
SC_SERVER_ERRORS
Any 5XX server error -
SC_INTERNAL_SERVER_ERROR
500 Internal Server Error -
SC_NOT_IMPLEMENTED
501 Not Implemented -
SC_BAD_GATEWAY
502 Bad Gateway -
SC_SERVICE_UNAVAILABLE
503 Service Unavailable -
SC_GATEWAY_TIMEOUT
504 Gateway Timeout -
SC_HTTP_VERSION_NOT_SUPPORTED
505 HTTP Version Not Supported -
SC_VARIANT_ALSO_NEGOTIATES
506 Variant Also Negotiates (RFC2295) -
SC_INSUFFICIENT_STORAGE
507 Insufficient Storage (WebDAV, RFC4918) -
SC_NOT_EXTENDED
510 Not Extended (RFC2774) -
SC_NETWORK_AUTHENTICATION_REQUIRED
511 Network Authentication Required (RFC6585) -
JSON
Creates a predicate validating the responsecontent-typeisapplication/json.
-
-
Constructor Details
-
ResponsePredicate
public ResponsePredicate(io.vertx.ext.web.client.predicate.ResponsePredicate delegate) -
ResponsePredicate
-
-
Method Details
-
getDelegate
public io.vertx.ext.web.client.predicate.ResponsePredicate getDelegate()- Specified by:
getDelegatein interfaceMutinyDelegate- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
apply
- Specified by:
applyin interfaceFunction<HttpResponse<Void>,ResponsePredicateResult>
-
status
Deprecated.- Parameters:
statusCode- the expected status code- Returns:
-
status
Deprecated.- Parameters:
min- the lower (inclusive) accepted status codemax- the highest (exclusive) accepted status code- Returns:
-
contentType
Deprecated.- Parameters:
mimeType- the mime type- Returns:
-
contentType
Deprecated.- Parameters:
mimeTypes- the list of mime types- Returns:
-
create
@Deprecated public static ResponsePredicate create(Function<HttpResponse<Void>, ResponsePredicateResult> test) Deprecated.- Parameters:
test- the function to invoke when the response is received- Returns:
-
create
@Deprecated public static ResponsePredicate create(Function<HttpResponse<Void>, ResponsePredicateResult> test, ErrorConverter errorConverter) Deprecated.- Parameters:
test- the function to invoke when the response is receivederrorConverter- converts the result of thetestfunction to aThrowable- Returns:
-
errorConverter
Deprecated.- Returns:
- the error converter currently used
-
newInstance
public static ResponsePredicate newInstance(io.vertx.ext.web.client.predicate.ResponsePredicate arg)
-