1 module hunt.http.codec.http.frame.HeadersFrame; 2 3 import hunt.http.HttpMetaData; 4 import hunt.http.codec.http.frame.Frame; 5 import hunt.http.codec.http.frame.PriorityFrame; 6 import hunt.http.codec.http.frame.FrameType; 7 8 import std.format; 9 10 class HeadersFrame : Frame { 11 private int streamId; 12 private HttpMetaData metaData; 13 private PriorityFrame priority; 14 private bool endStream; 15 16 /** 17 * <p> 18 * Creates a new {@code HEADERS} frame with an unspecified stream {@code id} 19 * . 20 * </p> 21 * <p> 22 * The stream {@code id} will be generated by the implementation while 23 * sending this frame to the other peer. 24 * </p> 25 * 26 * @param metaData 27 * the metadata containing HTTP request information 28 * @param priority 29 * the PRIORITY frame associated with this HEADERS frame 30 * @param endStream 31 * whether this frame ends the stream 32 */ 33 this(HttpMetaData metaData, PriorityFrame priority, bool endStream) { 34 this(0, metaData, priority, endStream); 35 } 36 37 /** 38 * <p> 39 * Creates a new {@code HEADERS} frame with the specified stream {@code id}. 40 * </p> 41 * <p> 42 * {@code HEADERS} frames with a specific stream {@code id} are typically 43 * used in responses to request {@code HEADERS} frames. 44 * </p> 45 * 46 * @param streamId 47 * the stream id 48 * @param metaData 49 * the metadata containing HTTP request/response information 50 * @param priority 51 * the PRIORITY frame associated with this HEADERS frame 52 * @param endStream 53 * whether this frame ends the stream 54 */ 55 this(int streamId, HttpMetaData metaData, PriorityFrame priority, bool endStream) { 56 super(FrameType.HEADERS); 57 this.streamId = streamId; 58 this.metaData = metaData; 59 this.priority = priority; 60 this.endStream = endStream; 61 } 62 63 int getStreamId() { 64 return streamId; 65 } 66 67 HttpMetaData getMetaData() { 68 return metaData; 69 } 70 71 PriorityFrame getPriority() { 72 return priority; 73 } 74 75 bool isEndStream() { 76 return endStream; 77 } 78 79 override 80 string toString() { 81 return format("%s#%d{end=%b}", super.toString(), streamId, endStream); 82 } 83 }