1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.http2.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.client.HttpReceiver;
25 import org.eclipse.jetty.client.HttpSender;
26 import org.eclipse.jetty.client.api.Result;
27 import org.eclipse.jetty.http2.api.Session;
28 import org.eclipse.jetty.http2.api.Stream;
29
30 public class HttpChannelOverHTTP2 extends HttpChannel
31 {
32 private final HttpConnectionOverHTTP2 connection;
33 private final Session session;
34 private final HttpSenderOverHTTP2 sender;
35 private final HttpReceiverOverHTTP2 receiver;
36
37 public HttpChannelOverHTTP2(HttpDestination destination, HttpConnectionOverHTTP2 connection, Session session)
38 {
39 super(destination);
40 this.connection = connection;
41 this.session = session;
42 this.sender = new HttpSenderOverHTTP2(this);
43 this.receiver = new HttpReceiverOverHTTP2(this);
44 }
45
46 public Session getSession()
47 {
48 return session;
49 }
50
51 public Stream.Listener getStreamListener()
52 {
53 return receiver;
54 }
55
56 @Override
57 protected HttpSender getHttpSender()
58 {
59 return sender;
60 }
61
62 @Override
63 protected HttpReceiver getHttpReceiver()
64 {
65 return receiver;
66 }
67
68 @Override
69 public void send()
70 {
71 HttpExchange exchange = getHttpExchange();
72 if (exchange != null)
73 sender.send(exchange);
74 }
75
76 @Override
77 public void release()
78 {
79 connection.release(this);
80 }
81
82 @Override
83 public void exchangeTerminated(HttpExchange exchange, Result result)
84 {
85 super.exchangeTerminated(exchange, result);
86 release();
87 }
88 }