1 //========================================================================
2 //Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
3 //------------------------------------------------------------------------
4 //All rights reserved. This program and the accompanying materials
5 //are made available under the terms of the Eclipse Public License v1.0
6 //and Apache License v2.0 which accompanies this distribution.
7 //The Eclipse Public License is available at
8 //http://www.eclipse.org/legal/epl-v10.html
9 //The Apache License v2.0 is available at
10 //http://www.opensource.org/licenses/apache2.0.php
11 //You may elect to redistribute this code under either of these licenses.
12 //========================================================================
13
14 package org.eclipse.jetty.spdy.api;
15
16 /**
17 * <p>A container for SYN_REPLY frames metadata and headers.</p>
18 */
19 public class ReplyInfo
20 {
21 /**
22 * <p>Flag that indicates that this {@link ReplyInfo} is the last frame in the stream.</p>
23 *
24 * @see #isClose()
25 * @see #getFlags()
26 */
27 public static final byte FLAG_CLOSE = 1;
28
29 private final Headers headers;
30 private final boolean close;
31
32 /**
33 * <p>Creates a new {@link ReplyInfo} instance with empty headers and the given close flag.</p>
34 *
35 * @param close the value of the close flag
36 */
37 public ReplyInfo(boolean close)
38 {
39 this(new Headers(), close);
40 }
41
42 /**
43 * <p>Creates a {@link ReplyInfo} instance with the given headers and the given close flag.</p>
44 *
45 * @param headers the {@link Headers}
46 * @param close the value of the close flag
47 */
48 public ReplyInfo(Headers headers, boolean close)
49 {
50 this.headers = headers;
51 this.close = close;
52 }
53
54 /**
55 * @return the {@link Headers}
56 */
57 public Headers getHeaders()
58 {
59 return headers;
60 }
61
62 /**
63 * @return the value of the close flag
64 */
65 public boolean isClose()
66 {
67 return close;
68 }
69
70 /**
71 * @return the close and reset compression flags as integer
72 * @see #FLAG_CLOSE
73 */
74 public byte getFlags()
75 {
76 return isClose() ? FLAG_CLOSE : 0;
77 }
78
79 @Override
80 public String toString()
81 {
82 return String.format("REPLY close=%b %s", close, headers);
83 }
84 }