Hi Ishaaq,

Sorry for the delay. This is clearly an advanced yet interesting use case!
We worked on it back when dealing the with SIP protocol (which uses a lot
of provisional HTTP-like responses).

The way it is intended to work in the Restlet API is very close to what Tim
is suggesting. It should even work at the ServerResource level when using
annotations. The main limitation is that you will need to rely on the
internal HTTP connector instead of Servlet/Simple/Jetty connectors as those
tend to swallow the Expect headers and immediately return 100 provisional
responses with no control given to the developer (as far as I remember,
needs to be verified).

The pseudo-code to do this is:

    @Put
    public String store(Representation largeEntity) throws IOException {
        for (Expectation expect : getClientInfo().getExpectations()) {
            if (expect.equals(Expectation.continueResponse())) {
                if (isValid(largeEntity)) {
                    setStatus(Status.INFO_CONTINUE);
                    commit();

                    // Do actual work
                    largeEntity.exhaust();
                    setStatus(Status.SUCCESS_OK);
                } else {
                    setStatus(Status.CLIENT_ERROR_EXPECTATION_FAILED);
                }
            }
        }

        return "OK";
    }

Note that when calling commit() with a 1xx status issues a provisional
responses but doesn't end the call until a final (non 1xx) response is
returned. There is a Response.isProvisional() method to test this.

Now, I've done a quick test with 2.2 trunk, and even though the provisional
100 response it returned correctly, the final response seems to hand my
RESTClient. Need to do more debugging.

Hope this helps,
Jerome
--
http://restlet.com
http://twitter.com/#!/jlouvel



2012/12/13 Ishaaq Chandy <ish...@gmail.com>

> Thanks for giving it a go anyway Tim.
>
> The fact that that Expectation class exists sort of indicates that someone
> must have got it working in the past, so yes, further clarification from
> the
> restlet guys wouldn't go astray
>
> Ishaaq
>
>
>
> --
> View this message in context:
> http://restlet-discuss.1400322.n2.nabble.com/expect-continue-handshake-tp7578505p7578517.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3035381
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3043654

Reply via email to