public static Response methodNotAllowed(final String methodName, final String... allowedMethods) { checkNotNull(methodName); checkNotNull(allowedMethods); checkArgument(allowedMethods.length != 0); return new Response.Builder() .status(Status.failure(METHOD_NOT_ALLOWED, methodName)) .header(HttpHeaders.ALLOW, Joiner.on(',').join(allowedMethods)) .build(); }
public static Response badGateway(@Nullable final String message) { return new Response.Builder() .status(Status.failure(BAD_GATEWAY, message)) .build(); }
public static Response badRequest(@Nullable final String message) { return new Response.Builder() .status(Status.failure(BAD_REQUEST, message)) .build(); }
public static Response unauthorized(@Nullable final String message) { return new Response.Builder() .status(Status.failure(UNAUTHORIZED, message)) .build(); }
public static Response forbidden(@Nullable final String message) { return new Response.Builder() .status(Status.failure(FORBIDDEN, message)) .build(); }
public static Response notFound(@Nullable final String message) { return new Response.Builder() .status(Status.failure(NOT_FOUND, message)) .build(); }
public static Response serviceUnavailable(@Nullable final String message) { return new Response.Builder() .status(Status.failure(SERVICE_UNAVAILABLE, message)) .build(); }
public static Response notImplemented(@Nullable final String message) { return new Response.Builder() .status(Status.failure(NOT_IMPLEMENTED, message)) .build(); }
@Nonnull static Response badCredentials(@Nullable final String message) { return new Response.Builder() .status(Status.failure(UNAUTHORIZED)) .payload(statusPayload(false, message)) .build(); } }
/** * Builds the challenge for authorization by setting a HTTP <code>401</code> (Unauthorized) status as well as the * response's <code>WWW-Authenticate</code> header. * <p/> * The header value constructed is equal to: * <p/> * <code>String.format("%s realm=\"%s\"", authenticationScheme, realmName)</code> * * @param message to be shown next to the status code * @param authenticationScheme authentication scheme used in the authentication challenge header * @param realmName realm name used in the authentication challenge header * @return a 401 authentication challenge response */ public static Response unauthorized(final String message, final String authenticationScheme, final String realmName) { checkNotNull(message); checkNotNull(authenticationScheme); checkNotNull(realmName); return new Response.Builder() .status(Status.failure(UNAUTHORIZED, message)) .header(HttpHeaders.WWW_AUTHENTICATE, String.format("%s realm=\"%s\"", authenticationScheme, realmName)) .build(); }
@Nonnull static Response badRequest(@Nullable final String message) { return new Response.Builder() .status(Status.failure(BAD_REQUEST)) .payload(statusPayload(false, message)) .build(); }
@Nonnull static Response notFound(@Nullable final String message) { return new Response.Builder() .status(Status.failure(NOT_FOUND, "Not Found")) .payload(statusPayload(false, message)) .build(); }
public static Response rangeNotSatisfiable(final long contentSize) { return new Response.Builder() .status(Status.failure(REQUESTED_RANGE_NOT_SATISFIABLE)) .header(HttpHeaders.CONTENT_LENGTH, "0") .header(HttpHeaders.CONTENT_RANGE, "bytes */" + contentSize) .build(); } }
.status(Status.failure(PRECONDITION_FAILED)) .payload(null) .build();