michael@0: /* michael@0: * ==================================================================== michael@0: * Licensed to the Apache Software Foundation (ASF) under one michael@0: * or more contributor license agreements. See the NOTICE file michael@0: * distributed with this work for additional information michael@0: * regarding copyright ownership. The ASF licenses this file michael@0: * to you under the Apache License, Version 2.0 (the michael@0: * "License"); you may not use this file except in compliance michael@0: * with the License. You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, michael@0: * software distributed under the License is distributed on an michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY michael@0: * KIND, either express or implied. See the License for the michael@0: * specific language governing permissions and limitations michael@0: * under the License. michael@0: * ==================================================================== michael@0: * michael@0: * This software consists of voluntary contributions made by many michael@0: * individuals on behalf of the Apache Software Foundation. For more michael@0: * information on the Apache Software Foundation, please see michael@0: * . michael@0: * michael@0: */ michael@0: michael@0: package ch.boye.httpclientandroidlib.protocol; michael@0: michael@0: import ch.boye.httpclientandroidlib.HttpException; michael@0: import ch.boye.httpclientandroidlib.HttpRequest; michael@0: import ch.boye.httpclientandroidlib.HttpResponse; michael@0: michael@0: /** michael@0: * Defines an interface to verify whether an incoming HTTP request meets michael@0: * the target server's expectations. michael@0: *

michael@0: * The Expect request-header field is used to indicate that particular michael@0: * server behaviors are required by the client. michael@0: *

michael@0: *
michael@0:  *    Expect       =  "Expect" ":" 1#expectation
michael@0:  *
michael@0:  *    expectation  =  "100-continue" | expectation-extension
michael@0:  *    expectation-extension =  token [ "=" ( token | quoted-string )
michael@0:  *                             *expect-params ]
michael@0:  *    expect-params =  ";" token [ "=" ( token | quoted-string ) ]
michael@0:  *
michael@0: *

michael@0: * A server that does not understand or is unable to comply with any of michael@0: * the expectation values in the Expect field of a request MUST respond michael@0: * with appropriate error status. The server MUST respond with a 417 michael@0: * (Expectation Failed) status if any of the expectations cannot be met michael@0: * or, if there are other problems with the request, some other 4xx michael@0: * status. michael@0: *

michael@0: * michael@0: * @since 4.0 michael@0: */ michael@0: public interface HttpExpectationVerifier { michael@0: michael@0: /** michael@0: * Verifies whether the given request meets the server's expectations. michael@0: *

michael@0: * If the request fails to meet particular criteria, this method can michael@0: * trigger a terminal response back to the client by setting the status michael@0: * code of the response object to a value greater or equal to michael@0: * 200. In this case the client will not have to transmit michael@0: * the request body. If the request meets expectations this method can michael@0: * terminate without modifying the response object. Per default the status michael@0: * code of the response object will be set to 100. michael@0: * michael@0: * @param request the HTTP request. michael@0: * @param response the HTTP response. michael@0: * @param context the HTTP context. michael@0: * @throws HttpException in case of an HTTP protocol violation. michael@0: */ michael@0: void verify(HttpRequest request, HttpResponse response, HttpContext context) michael@0: throws HttpException; michael@0: michael@0: }