1 //
2 // ========================================================================
3 // Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.server;
20
21 import java.nio.ByteBuffer;
22
23 import org.eclipse.jetty.http.MetaData;
24 import org.eclipse.jetty.util.Callback;
25
26
27 /* ------------------------------------------------------------ */
28 /** Abstraction of the outbound HTTP transport.
29 */
30 public interface HttpTransport
31 {
32 void send(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, Callback callback);
33
34 boolean isPushSupported();
35
36 void push(MetaData.Request request);
37
38 void onCompleted();
39
40 /**
41 * Aborts this transport.
42 * <p>
43 * This method should terminate the transport in a way that
44 * can indicate an abnormal response to the client, for example
45 * by abruptly close the connection.
46 * <p>
47 * This method is called when an error response needs to be sent,
48 * but the response is already committed, or when a write failure
49 * is detected.
50 *
51 * @param failure the failure that caused the abort.
52 */
53 void abort(Throwable failure);
54
55 /* ------------------------------------------------------------ */
56 /** Is the underlying transport optimized for DirectBuffer usage
57 * @return True if direct buffers can be used optimally.
58 */
59 boolean isOptimizedForDirectBuffers();
60 }