View Javadoc

1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.http.nio.protocol;
29  
30  import java.io.IOException;
31  import java.io.OutputStream;
32  import java.util.concurrent.Executor;
33  
34  import org.apache.http.ConnectionReuseStrategy;
35  import org.apache.http.HttpEntity;
36  import org.apache.http.HttpEntityEnclosingRequest;
37  import org.apache.http.HttpException;
38  import org.apache.http.HttpRequest;
39  import org.apache.http.HttpResponse;
40  import org.apache.http.HttpResponseFactory;
41  import org.apache.http.HttpStatus;
42  import org.apache.http.HttpVersion;
43  import org.apache.http.MethodNotSupportedException;
44  import org.apache.http.ProtocolException;
45  import org.apache.http.ProtocolVersion;
46  import org.apache.http.UnsupportedHttpVersionException;
47  import org.apache.http.annotation.ThreadingBehavior;
48  import org.apache.http.annotation.Contract;
49  import org.apache.http.entity.ByteArrayEntity;
50  import org.apache.http.nio.ContentDecoder;
51  import org.apache.http.nio.ContentEncoder;
52  import org.apache.http.nio.IOControl;
53  import org.apache.http.nio.NHttpConnection;
54  import org.apache.http.nio.NHttpServerConnection;
55  import org.apache.http.nio.NHttpServiceHandler;
56  import org.apache.http.nio.entity.ContentBufferEntity;
57  import org.apache.http.nio.entity.ContentOutputStream;
58  import org.apache.http.nio.params.NIOReactorPNames;
59  import org.apache.http.nio.util.ByteBufferAllocator;
60  import org.apache.http.nio.util.ContentInputBuffer;
61  import org.apache.http.nio.util.ContentOutputBuffer;
62  import org.apache.http.nio.util.DirectByteBufferAllocator;
63  import org.apache.http.nio.util.SharedInputBuffer;
64  import org.apache.http.nio.util.SharedOutputBuffer;
65  import org.apache.http.params.DefaultedHttpParams;
66  import org.apache.http.params.HttpParams;
67  import org.apache.http.protocol.ExecutionContext;
68  import org.apache.http.protocol.HttpContext;
69  import org.apache.http.protocol.HttpExpectationVerifier;
70  import org.apache.http.protocol.HttpProcessor;
71  import org.apache.http.protocol.HttpRequestHandler;
72  import org.apache.http.protocol.HttpRequestHandlerResolver;
73  import org.apache.http.util.Args;
74  import org.apache.http.util.EncodingUtils;
75  import org.apache.http.util.EntityUtils;
76  
77  /**
78   * Service protocol handler implementation that provide compatibility with
79   * the blocking I/O by utilizing shared content buffers and a fairly small pool
80   * of worker threads. The throttling protocol handler allocates input / output
81   * buffers of a constant length upon initialization and controls the rate of
82   * I/O events in order to ensure those content buffers do not ever get
83   * overflown. This helps ensure nearly constant memory footprint for HTTP
84   * connections and avoid the out of memory condition while streaming content
85   * in and out. The {@link HttpRequestHandler#handle(HttpRequest, HttpResponse, HttpContext)}
86   * method will fire immediately when a message is received. The protocol handler
87   * delegate the task of processing requests and generating response content to
88   * an {@link Executor}, which is expected to perform those tasks using
89   * dedicated worker threads in order to avoid blocking the I/O thread.
90   * <p>
91   * Usually throttling protocol handlers need only a modest number of worker
92   * threads, much fewer than the number of concurrent connections. If the length
93   * of the message is smaller or about the size of the shared content buffer
94   * worker thread will just store content in the buffer and terminate almost
95   * immediately without blocking. The I/O dispatch thread in its turn will take
96   * care of sending out the buffered content asynchronously. The worker thread
97   * will have to block only when processing large messages and the shared buffer
98   * fills up. It is generally advisable to allocate shared buffers of a size of
99   * an average content body for optimal performance.
100  * <p>
101  * The following parameters can be used to customize the behavior of this
102  * class:
103  * <ul>
104  *  <li>{@link org.apache.http.nio.params.NIOReactorPNames#CONTENT_BUFFER_SIZE}</li>
105  *  <li>{@link org.apache.http.params.CoreProtocolPNames#WAIT_FOR_CONTINUE}</li>
106  * </ul>
107  *
108  * @since 4.0
109  *
110  * @deprecated (4.2) use {@link HttpAsyncService}
111  */
112 @Deprecated
113 @Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
114 public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
115                                           implements NHttpServiceHandler {
116 
117     protected final HttpResponseFactory responseFactory;
118     protected final Executor executor;
119 
120     protected HttpRequestHandlerResolver handlerResolver;
121     protected HttpExpectationVerifier expectationVerifier;
122 
123     private final int bufsize;
124 
125     public ThrottlingHttpServiceHandler(
126             final HttpProcessor httpProcessor,
127             final HttpResponseFactory responseFactory,
128             final ConnectionReuseStrategy connStrategy,
129             final ByteBufferAllocator allocator,
130             final Executor executor,
131             final HttpParams params) {
132         super(httpProcessor, connStrategy, allocator, params);
133         Args.notNull(responseFactory, "Response factory");
134         Args.notNull(executor, "Executor");
135         this.responseFactory = responseFactory;
136         this.executor = executor;
137         this.bufsize = this.params.getIntParameter(NIOReactorPNames.CONTENT_BUFFER_SIZE, 20480);
138     }
139 
140     public ThrottlingHttpServiceHandler(
141             final HttpProcessor httpProcessor,
142             final HttpResponseFactory responseFactory,
143             final ConnectionReuseStrategy connStrategy,
144             final Executor executor,
145             final HttpParams params) {
146         this(httpProcessor, responseFactory, connStrategy,
147                 DirectByteBufferAllocator.INSTANCE, executor, params);
148     }
149 
150     public void setHandlerResolver(final HttpRequestHandlerResolver handlerResolver) {
151         this.handlerResolver = handlerResolver;
152     }
153 
154     public void setExpectationVerifier(final HttpExpectationVerifier expectationVerifier) {
155         this.expectationVerifier = expectationVerifier;
156     }
157 
158     public void connected(final NHttpServerConnection conn) {
159         final HttpContext context = conn.getContext();
160 
161         final ServerConnState connState = new ServerConnState(this.bufsize, conn, allocator);
162         context.setAttribute(CONN_STATE, connState);
163 
164         if (this.eventListener != null) {
165             this.eventListener.connectionOpen(conn);
166         }
167     }
168 
169     public void closed(final NHttpServerConnection conn) {
170         final HttpContext context = conn.getContext();
171         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
172 
173         if (connState != null) {
174             synchronized (connState) {
175                 connState.close();
176                 connState.notifyAll();
177             }
178         }
179 
180         if (this.eventListener != null) {
181             this.eventListener.connectionClosed(conn);
182         }
183     }
184 
185     public void exception(final NHttpServerConnection conn, final HttpException httpex) {
186         if (conn.isResponseSubmitted()) {
187             if (eventListener != null) {
188                 eventListener.fatalProtocolException(httpex, conn);
189             }
190             return;
191         }
192 
193         final HttpContext context = conn.getContext();
194 
195         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
196 
197         try {
198 
199             final HttpResponse response = this.responseFactory.newHttpResponse(
200                     HttpVersion.HTTP_1_0,
201                     HttpStatus.SC_INTERNAL_SERVER_ERROR,
202                     context);
203             response.setParams(
204                     new DefaultedHttpParams(response.getParams(), this.params));
205             handleException(httpex, response);
206             response.setEntity(null);
207 
208             this.httpProcessor.process(response, context);
209 
210             synchronized (connState) {
211                 connState.setResponse(response);
212                 // Response is ready to be committed
213                 conn.requestOutput();
214             }
215 
216         } catch (final IOException ex) {
217             shutdownConnection(conn, ex);
218             if (eventListener != null) {
219                 eventListener.fatalIOException(ex, conn);
220             }
221         } catch (final HttpException ex) {
222             closeConnection(conn, ex);
223             if (eventListener != null) {
224                 eventListener.fatalProtocolException(ex, conn);
225             }
226         }
227     }
228 
229     public void exception(final NHttpServerConnection conn, final IOException ex) {
230         shutdownConnection(conn, ex);
231 
232         if (this.eventListener != null) {
233             this.eventListener.fatalIOException(ex, conn);
234         }
235     }
236 
237     public void timeout(final NHttpServerConnection conn) {
238         handleTimeout(conn);
239     }
240 
241     public void requestReceived(final NHttpServerConnection conn) {
242         final HttpContext context = conn.getContext();
243 
244         final HttpRequest request = conn.getHttpRequest();
245         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
246 
247         synchronized (connState) {
248             boolean contentExpected = false;
249             if (request instanceof HttpEntityEnclosingRequest) {
250                 final HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
251                 if (entity != null) {
252                     contentExpected = true;
253                 }
254             }
255 
256             if (!contentExpected) {
257                 conn.suspendInput();
258             }
259 
260             this.executor.execute(new Runnable() {
261 
262                 public void run() {
263                     try {
264 
265                         handleRequest(request, connState, conn);
266 
267                     } catch (final IOException ex) {
268                         shutdownConnection(conn, ex);
269                         if (eventListener != null) {
270                             eventListener.fatalIOException(ex, conn);
271                         }
272                     } catch (final HttpException ex) {
273                         shutdownConnection(conn, ex);
274                         if (eventListener != null) {
275                             eventListener.fatalProtocolException(ex, conn);
276                         }
277                     }
278                 }
279 
280             });
281 
282             connState.notifyAll();
283         }
284 
285     }
286 
287     public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder) {
288         final HttpContext context = conn.getContext();
289 
290         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
291 
292         try {
293 
294             synchronized (connState) {
295                 final ContentInputBuffer buffer = connState.getInbuffer();
296 
297                 buffer.consumeContent(decoder);
298                 if (decoder.isCompleted()) {
299                     connState.setInputState(ServerConnState.REQUEST_BODY_DONE);
300                 } else {
301                     connState.setInputState(ServerConnState.REQUEST_BODY_STREAM);
302                 }
303 
304                 connState.notifyAll();
305             }
306 
307         } catch (final IOException ex) {
308             shutdownConnection(conn, ex);
309             if (this.eventListener != null) {
310                 this.eventListener.fatalIOException(ex, conn);
311             }
312         }
313 
314     }
315 
316     public void responseReady(final NHttpServerConnection conn) {
317         final HttpContext context = conn.getContext();
318 
319         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
320 
321         try {
322 
323             synchronized (connState) {
324                 if (connState.isExpectationFailed()) {
325                     // Server expection failed
326                     // Well-behaved client will not be sending
327                     // a request body
328                     conn.resetInput();
329                     connState.setExpectationFailed(false);
330                 }
331 
332                 final HttpResponse response = connState.getResponse();
333                 if (connState.getOutputState() == ServerConnState.READY
334                         && response != null
335                         && !conn.isResponseSubmitted()) {
336 
337                     conn.submitResponse(response);
338                     final int statusCode = response.getStatusLine().getStatusCode();
339                     final HttpEntity entity = response.getEntity();
340 
341                     if (statusCode >= 200 && entity == null) {
342                         connState.setOutputState(ServerConnState.RESPONSE_DONE);
343 
344                         if (!this.connStrategy.keepAlive(response, context)) {
345                             conn.close();
346                         }
347                     } else {
348                         connState.setOutputState(ServerConnState.RESPONSE_SENT);
349                     }
350                 }
351 
352                 connState.notifyAll();
353             }
354 
355         } catch (final IOException ex) {
356             shutdownConnection(conn, ex);
357             if (eventListener != null) {
358                 eventListener.fatalIOException(ex, conn);
359             }
360         } catch (final HttpException ex) {
361             closeConnection(conn, ex);
362             if (eventListener != null) {
363                 eventListener.fatalProtocolException(ex, conn);
364             }
365         }
366     }
367 
368     public void outputReady(final NHttpServerConnection conn, final ContentEncoder encoder) {
369         final HttpContext context = conn.getContext();
370 
371         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
372 
373         try {
374 
375             synchronized (connState) {
376                 final HttpResponse response = connState.getResponse();
377                 final ContentOutputBuffer buffer = connState.getOutbuffer();
378 
379                 buffer.produceContent(encoder);
380                 if (encoder.isCompleted()) {
381                     connState.setOutputState(ServerConnState.RESPONSE_BODY_DONE);
382 
383                     if (!this.connStrategy.keepAlive(response, context)) {
384                         conn.close();
385                     }
386                 } else {
387                     connState.setOutputState(ServerConnState.RESPONSE_BODY_STREAM);
388                 }
389 
390                 connState.notifyAll();
391             }
392 
393         } catch (final IOException ex) {
394             shutdownConnection(conn, ex);
395             if (this.eventListener != null) {
396                 this.eventListener.fatalIOException(ex, conn);
397             }
398         }
399     }
400 
401     private void handleException(final HttpException ex, final HttpResponse response) {
402         if (ex instanceof MethodNotSupportedException) {
403             response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
404         } else if (ex instanceof UnsupportedHttpVersionException) {
405             response.setStatusCode(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED);
406         } else if (ex instanceof ProtocolException) {
407             response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
408         } else {
409             response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
410         }
411         final byte[] msg = EncodingUtils.getAsciiBytes(ex.getMessage());
412         final ByteArrayEntity entity = new ByteArrayEntity(msg);
413         entity.setContentType("text/plain; charset=US-ASCII");
414         response.setEntity(entity);
415     }
416 
417     private void handleRequest(
418             final HttpRequest request,
419             final ServerConnState connState,
420             final NHttpServerConnection conn) throws HttpException, IOException {
421 
422         final HttpContext context = conn.getContext();
423 
424         // Block until previous request is fully processed and
425         // the worker thread no longer holds the shared buffer
426         synchronized (connState) {
427             try {
428                 for (;;) {
429                     final int currentState = connState.getOutputState();
430                     if (currentState == ServerConnState.READY) {
431                         break;
432                     }
433                     if (currentState == ServerConnState.SHUTDOWN) {
434                         return;
435                     }
436                     connState.wait();
437                 }
438             } catch (final InterruptedException ex) {
439                 connState.shutdown();
440                 return;
441             }
442             connState.setInputState(ServerConnState.REQUEST_RECEIVED);
443             connState.setRequest(request);
444         }
445 
446         request.setParams(new DefaultedHttpParams(request.getParams(), this.params));
447 
448         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
449         context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
450 
451         ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
452 
453         if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
454             // Downgrade protocol version if greater than HTTP/1.1
455             ver = HttpVersion.HTTP_1_1;
456         }
457 
458         HttpResponse response = null;
459 
460         if (request instanceof HttpEntityEnclosingRequest) {
461             final HttpEntityEnclosingRequest eeRequest = (HttpEntityEnclosingRequest) request;
462 
463             if (eeRequest.expectContinue()) {
464                 response = this.responseFactory.newHttpResponse(
465                         ver,
466                         HttpStatus.SC_CONTINUE,
467                         context);
468                 response.setParams(
469                         new DefaultedHttpParams(response.getParams(), this.params));
470                 if (this.expectationVerifier != null) {
471                     try {
472                         this.expectationVerifier.verify(request, response, context);
473                     } catch (final HttpException ex) {
474                         response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0,
475                                 HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
476                         response.setParams(
477                                 new DefaultedHttpParams(response.getParams(), this.params));
478                         handleException(ex, response);
479                     }
480                 }
481 
482                 synchronized (connState) {
483                     if (response.getStatusLine().getStatusCode() < 200) {
484                         // Send 1xx response indicating the server expections
485                         // have been met
486                         connState.setResponse(response);
487                         conn.requestOutput();
488 
489                         // Block until 1xx response is sent to the client
490                         try {
491                             for (;;) {
492                                 final int currentState = connState.getOutputState();
493                                 if (currentState == ServerConnState.RESPONSE_SENT) {
494                                     break;
495                                 }
496                                 if (currentState == ServerConnState.SHUTDOWN) {
497                                     return;
498                                 }
499                                 connState.wait();
500                             }
501                         } catch (final InterruptedException ex) {
502                             connState.shutdown();
503                             return;
504                         }
505                         connState.resetOutput();
506                         response = null;
507                     } else {
508                         // Discard request entity
509                         eeRequest.setEntity(null);
510                         conn.suspendInput();
511                         connState.setExpectationFailed(true);
512                     }
513                 }
514             }
515 
516             // Create a wrapper entity instead of the original one
517             if (eeRequest.getEntity() != null) {
518                 eeRequest.setEntity(new ContentBufferEntity(
519                         eeRequest.getEntity(),
520                         connState.getInbuffer()));
521             }
522 
523         }
524 
525         if (response == null) {
526             response = this.responseFactory.newHttpResponse(
527                     ver,
528                     HttpStatus.SC_OK,
529                     context);
530             response.setParams(
531                     new DefaultedHttpParams(response.getParams(), this.params));
532 
533             context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
534 
535             try {
536 
537                 this.httpProcessor.process(request, context);
538 
539                 HttpRequestHandler handler = null;
540                 if (this.handlerResolver != null) {
541                     final String requestURI = request.getRequestLine().getUri();
542                     handler = this.handlerResolver.lookup(requestURI);
543                 }
544                 if (handler != null) {
545                     handler.handle(request, response, context);
546                 } else {
547                     response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
548                 }
549 
550             } catch (final HttpException ex) {
551                 response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0,
552                         HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
553                 response.setParams(
554                         new DefaultedHttpParams(response.getParams(), this.params));
555                 handleException(ex, response);
556             }
557         }
558 
559         if (request instanceof HttpEntityEnclosingRequest) {
560             final HttpEntityEnclosingRequest eeRequest = (HttpEntityEnclosingRequest) request;
561             final HttpEntity entity = eeRequest.getEntity();
562             EntityUtils.consume(entity);
563         }
564 
565         // It should be safe to reset the input state at this point
566         connState.resetInput();
567 
568         this.httpProcessor.process(response, context);
569 
570         if (!canResponseHaveBody(request, response)) {
571             response.setEntity(null);
572         }
573 
574         connState.setResponse(response);
575         // Response is ready to be committed
576         conn.requestOutput();
577 
578         if (response.getEntity() != null) {
579             final ContentOutputBuffer buffer = connState.getOutbuffer();
580             final OutputStream outstream = new ContentOutputStream(buffer);
581 
582             final HttpEntity entity = response.getEntity();
583             entity.writeTo(outstream);
584             outstream.flush();
585             outstream.close();
586         }
587 
588         synchronized (connState) {
589             try {
590                 for (;;) {
591                     final int currentState = connState.getOutputState();
592                     if (currentState == ServerConnState.RESPONSE_DONE) {
593                         break;
594                     }
595                     if (currentState == ServerConnState.SHUTDOWN) {
596                         return;
597                     }
598                     connState.wait();
599                 }
600             } catch (final InterruptedException ex) {
601                 connState.shutdown();
602                 return;
603             }
604             connState.resetOutput();
605             conn.requestInput();
606             connState.notifyAll();
607         }
608     }
609 
610     @Override
611     protected void shutdownConnection(final NHttpConnection conn, final Throwable cause) {
612         final HttpContext context = conn.getContext();
613 
614         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
615 
616         super.shutdownConnection(conn, cause);
617 
618         if (connState != null) {
619             connState.shutdown();
620         }
621     }
622 
623     static class ServerConnState {
624 
625         public static final int SHUTDOWN                   = -1;
626         public static final int READY                      = 0;
627         public static final int REQUEST_RECEIVED           = 1;
628         public static final int REQUEST_BODY_STREAM        = 2;
629         public static final int REQUEST_BODY_DONE          = 4;
630         public static final int RESPONSE_SENT              = 8;
631         public static final int RESPONSE_BODY_STREAM       = 16;
632         public static final int RESPONSE_BODY_DONE         = 32;
633         public static final int RESPONSE_DONE              = 32;
634 
635         private final SharedInputBuffer inbuffer;
636         private final SharedOutputBuffer outbuffer;
637 
638         private volatile int inputState;
639         private volatile int outputState;
640 
641         private volatile HttpRequest request;
642         private volatile HttpResponse response;
643 
644         private volatile boolean expectationFailure;
645 
646         public ServerConnState(
647                 final int bufsize,
648                 final IOControl ioControl,
649                 final ByteBufferAllocator allocator) {
650             super();
651             this.inbuffer = new SharedInputBuffer(bufsize, ioControl, allocator);
652             this.outbuffer = new SharedOutputBuffer(bufsize, ioControl, allocator);
653             this.inputState = READY;
654             this.outputState = READY;
655         }
656 
657         public ContentInputBuffer getInbuffer() {
658             return this.inbuffer;
659         }
660 
661         public ContentOutputBuffer getOutbuffer() {
662             return this.outbuffer;
663         }
664 
665         public int getInputState() {
666             return this.inputState;
667         }
668 
669         public void setInputState(final int inputState) {
670             this.inputState = inputState;
671         }
672 
673         public int getOutputState() {
674             return this.outputState;
675         }
676 
677         public void setOutputState(final int outputState) {
678             this.outputState = outputState;
679         }
680 
681         public HttpRequest getRequest() {
682             return this.request;
683         }
684 
685         public void setRequest(final HttpRequest request) {
686             this.request = request;
687         }
688 
689         public HttpResponse getResponse() {
690             return this.response;
691         }
692 
693         public void setResponse(final HttpResponse response) {
694             this.response = response;
695         }
696 
697         public boolean isExpectationFailed() {
698             return expectationFailure;
699         }
700 
701         public void setExpectationFailed(final boolean b) {
702             this.expectationFailure = b;
703         }
704 
705         public void close() {
706             this.inbuffer.close();
707             this.outbuffer.close();
708             this.inputState = SHUTDOWN;
709             this.outputState = SHUTDOWN;
710         }
711 
712         public void shutdown() {
713             this.inbuffer.shutdown();
714             this.outbuffer.shutdown();
715             this.inputState = SHUTDOWN;
716             this.outputState = SHUTDOWN;
717         }
718 
719         public void resetInput() {
720             this.inbuffer.reset();
721             this.request = null;
722             this.inputState = READY;
723         }
724 
725         public void resetOutput() {
726             this.outbuffer.reset();
727             this.response = null;
728             this.outputState = READY;
729             this.expectationFailure = false;
730         }
731 
732     }
733 
734 }