| java.lang.Object HTTPClient.IdempotentSequence
IdempotentSequence | class IdempotentSequence (Code) | | This class checks whether a sequence of requests is idempotent. This
is used to determine which requests may be automatically retried. This
class also serves as a central place to record which methods have side
effects and which methods are idempotent.
Note: unknown methods (i.e. a method which is not HEAD, GET, POST,
PUT, DELETE, OPTIONS or TRACE) are treated conservatively, meaning
they are assumed to have side effects and are not idempotent.
Usage:
IdempotentSequence seq = new IdempotentSequence();
seq.add(r1);
...
if (seq.isIdempotent(r1)) ...
...
version: 0.3-2 18/06/1999 author: Ronald Tschalär |
Method Summary | |
public void | add(Request req) Add the request to the end of the list of requests. | public boolean | isIdempotent(Request req) Is this request part of an idempotent sequence? This method must
not be called before all requests have been added to this
sequence; similarly, add() must not be called
after this method was invoked.
We split up the sequence of requests into individual sub-sequences,
or threads, with all requests in a thread having the same request-URI
and no two threads having the same request-URI. | public static void | main(String args) Test code. | public static boolean | methodHasSideEffects(String method) | public static boolean | methodIsComplete(String method) A method is complete if any side effects of the request affect
the complete resource. | public static boolean | methodIsIdempotent(String method) A method is idempotent if the side effects of N identical
requests is the same as for a single request (Section 9.1.2
of RFC-????). |
IdempotentSequence | public IdempotentSequence()(Code) | | Start a new sequence of requests.
|
add | public void add(Request req)(Code) | | Add the request to the end of the list of requests. This is used
to build the complete sequence of requests before determining
whether the sequence is idempotent.
Parameters: req - the next request |
isIdempotent | public boolean isIdempotent(Request req)(Code) | | Is this request part of an idempotent sequence? This method must
not be called before all requests have been added to this
sequence; similarly, add() must not be called
after this method was invoked.
We split up the sequence of requests into individual sub-sequences,
or threads, with all requests in a thread having the same request-URI
and no two threads having the same request-URI. Each thread is then
marked as idempotent or not according to the following rules:
- If any method is UNKNOWN then the thread is not idempotent;
- else, if no method has side effects then the thread is idempotent;
- else, if the first method has side effects and is complete then
the thread is idempotent;
- else, if the first method has side effects, is not complete,
and no other method has side effects then the thread is idempotent;
- else the thread is not idempotent.
The major assumption here is that the side effects of any method
only apply to resource specified. E.g. a "PUT /barbara.html"
will only affect the resource "/barbara.html" and nothing else.
This assumption is violated by POST of course; however, POSTs are
not pipelined and will therefore never show up here.
Parameters: req - the request |
methodHasSideEffects | public static boolean methodHasSideEffects(String method)(Code) | | |
methodIsComplete | public static boolean methodIsComplete(String method)(Code) | | A method is complete if any side effects of the request affect
the complete resource. For example, a PUT is complete but a
PUT with byte-ranges wouldn't be. In essence, if a request uses
a method which has side effects and is complete then the state
of the resource after the request is independent of the state of
the resource before the request.
true if method is complete |
methodIsIdempotent | public static boolean methodIsIdempotent(String method)(Code) | | A method is idempotent if the side effects of N identical
requests is the same as for a single request (Section 9.1.2
of RFC-????).
true if method is idempotent |
|
|