View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 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.spdy.client.http;
20  
21  import org.eclipse.jetty.client.HttpChannel;
22  import org.eclipse.jetty.client.HttpDestination;
23  import org.eclipse.jetty.client.HttpExchange;
24  import org.eclipse.jetty.spdy.api.Session;
25  
26  public class HttpChannelOverSPDY extends HttpChannel
27  {
28      private final Session session;
29      private final HttpSenderOverSPDY sender;
30      private final HttpReceiverOverSPDY receiver;
31  
32      public HttpChannelOverSPDY(HttpDestination destination, Session session)
33      {
34          super(destination);
35          this.session = session;
36          this.sender = new HttpSenderOverSPDY(this);
37          this.receiver = new HttpReceiverOverSPDY(this);
38      }
39  
40      public Session getSession()
41      {
42          return session;
43      }
44  
45      public HttpSenderOverSPDY getHttpSender()
46      {
47          return sender;
48      }
49  
50      public HttpReceiverOverSPDY getHttpReceiver()
51      {
52          return receiver;
53      }
54  
55      @Override
56      public void send()
57      {
58          HttpExchange exchange = getHttpExchange();
59          if (exchange != null)
60              sender.send(exchange);
61      }
62  
63      @Override
64      public void proceed(HttpExchange exchange, boolean proceed)
65      {
66          sender.proceed(exchange, proceed);
67      }
68  
69      @Override
70      public boolean abort(Throwable cause)
71      {
72          sender.abort(cause);
73          return receiver.abort(cause);
74      }
75  }