MCPcopy Index your code
hub / github.com/apache/tomcat / TestOutput

Class TestOutput

test/org/apache/coyote/http2/Http2TestBase.java:1113–1353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111
1112
1113 public class TestOutput implements Output, HeaderEmitter {
1114
1115 private final boolean autoAckSettings;
1116
1117 private StringBuffer trace = new StringBuffer();
1118 private String lastStreamId = "0";
1119 private ConnectionSettingsRemote remoteSettings = new ConnectionSettingsRemote("-1");
1120 private boolean traceBody = false;
1121 private ByteBuffer bodyBuffer = null;
1122 private long bytesRead;
1123 private volatile HpackDecoder hpackDecoder = null;
1124
1125 public TestOutput(boolean autoAckSettings) {
1126 this.autoAckSettings = autoAckSettings;
1127 }
1128
1129 public void setTraceBody(boolean traceBody) {
1130 this.traceBody = traceBody;
1131 }
1132
1133
1134 @Override
1135 public HpackDecoder getHpackDecoder() {
1136 if (hpackDecoder == null) {
1137 synchronized (this) {
1138 if (hpackDecoder == null) {
1139 hpackDecoder = new HpackDecoder(remoteSettings.getHeaderTableSize());
1140 }
1141 }
1142 }
1143 return hpackDecoder;
1144 }
1145
1146
1147 @Override
1148 public ByteBuffer startRequestBodyFrame(int streamId, int dataLength, boolean endOfStream) {
1149 lastStreamId = Integer.toString(streamId);
1150 bytesRead += dataLength;
1151 if (traceBody) {
1152 bodyBuffer = ByteBuffer.allocate(dataLength);
1153 return bodyBuffer;
1154 } else {
1155 trace.append(lastStreamId + "-Body-" + dataLength + "\n");
1156 return null;
1157 }
1158 }
1159
1160
1161 @Override
1162 public void endRequestBodyFrame(int streamId, int dataLength) throws Http2Exception {
1163 if (bodyBuffer != null) {
1164 if (bodyBuffer.limit() > 0) {
1165 trace.append(lastStreamId + "-Body-");
1166 bodyBuffer.flip();
1167 while (bodyBuffer.hasRemaining()) {
1168 trace.append((char) bodyBuffer.get());
1169 }
1170 trace.append("\n");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected