hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: HttpAsyncExpectationVerifier question
Date Sat, 20 May 2017 16:52:02 GMT
OK, cool, my next issue (in the same method) is that the verifier is NOT
called for all requests, which is a bug for my use case. I can see that it
is only called for HttpEntityEnclosingRequest so I cannot verify all
requests coming in!

        if (request instanceof HttpEntityEnclosingRequest) {

            // If 100-continue is expected make sure
            // there is no pending response data, no pipelined requests or
buffered input
            if (((HttpEntityEnclosingRequest) request).expectContinue()
                        && state.getResponseState() == MessageState.READY
                        && state.getPipeline().isEmpty()
                        && !(conn instanceof SessionBufferStatus &&
((SessionBufferStatus) conn).hasBufferedInput())) {

                state.setRequestState(MessageState.ACK_EXPECTED);
                final HttpResponse ack =
this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_1,
                        HttpStatus.SC_CONTINUE, context);
                if (this.expectationVerifier != null) {
                    conn.suspendInput();
                    conn.suspendOutput();
                    final HttpAsyncExchange httpAsyncExchange = new
HttpAsyncExchangeImpl(
                            request, ack, state, conn, context);
                    this.expectationVerifier.verify(httpAsyncExchange,
context);
                } else {
                    conn.submitResponse(ack);
                    state.setRequestState(MessageState.BODY_STREAM);
                }
            } else {
                state.setRequestState(MessageState.BODY_STREAM);
            }
        } else {
            // No request content is expected. Process request right away
            completeRequest(incoming, conn, state);
        }
    }

I do not see a way to hack this. I cannot even clone the whole class (ugly)
since it refers to package private code.

Thoughts?

Gary


On Sat, May 20, 2017 at 1:46 AM, Oleg Kalnichevski <olegk@apache.org> wrote:

> On Fri, 2017-05-19 at 16:30 -0700, Gary Gregory wrote:
> > Hi All,
> >
> > I'm trying to understand the implications of using
> > a HttpAsyncExpectationVerifier.
> >
> > I see only one call site and no tests:
> >
>
> There are quite a few tests
>
> https://github.com/apache/httpcomponents-core/blob/4.4.x/httpcore-nio/s
> rc/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
> #L407
>
>
> > org.apache.http.nio.protocol.HttpAsyncService.requestReceived(NHttpSe
> > rverConnection):
> >
> > ...
> >                 if (this.expectationVerifier != null) {
> >                     conn.suspendInput();
> >                     conn.suspendOutput();
> >                     final HttpAsyncExchange httpAsyncExchange = new
> > HttpAsyncExchangeImpl(
> >                             request, ack, state, conn, context);
> >                     this.expectationVerifier.verify(httpAsyncExchange
> > ,
> > context);
> >                 } else {
> >                     conn.submitResponse(ack);
> >                     state.setRequestState(MessageState.BODY_STREAM);
> >                 }
> > ...
> >
> >
> > So my expectationVerifier MUST eventually:
> >
> > (1) call:
> >
> >                     conn.submitResponse(ack);
> >                     state.setRequestState(MessageState.BODY_STREAM);
> >
> > or (2) throw an HttpException
> >
> > Right?
> >
>
> Correct.
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message