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

Method emitHeader

java/org/apache/coyote/http2/Stream.java:322–514  ·  view source on GitHub ↗
(String name, String value)

Source from the content-addressed store, hash-verified

320
321
322 @Override
323 public final void emitHeader(String name, String value) throws HpackException {
324 if (log.isTraceEnabled()) {
325 log.trace(sm.getString("stream.header.debug", getConnectionId(), getIdAsString(), name, value));
326 }
327
328 // Field header names being all lower case is enforced in HpackDecoder.
329
330 if (HTTP_CONNECTION_SPECIFIC_HEADERS.contains(name)) {
331 headerException = new StreamException(
332 sm.getString("stream.header.connection", getConnectionId(), getIdAsString(), name),
333 Http2Error.PROTOCOL_ERROR, getIdAsInt());
334 // No need for further processing. The stream will be reset.
335 return;
336 }
337
338 if ("te".equals(name)) {
339 if (!"trailers".equals(value)) {
340 headerException =
341 new StreamException(sm.getString("stream.header.te", getConnectionId(), getIdAsString(), value),
342 Http2Error.PROTOCOL_ERROR, getIdAsInt());
343 // No need for further processing. The stream will be reset.
344 return;
345 }
346 }
347
348 if (headerException != null) {
349 // Don't bother processing the header since the stream is going to
350 // be reset anyway
351 return;
352 }
353
354 if (name.isEmpty()) {
355 headerException =
356 new StreamException(sm.getString("stream.header.empty", getConnectionId(), getIdAsString()),
357 Http2Error.PROTOCOL_ERROR, getIdAsInt());
358 // No need for further processing. The stream will be reset.
359 return;
360 }
361
362 boolean pseudoHeader = name.charAt(0) == ':';
363
364 if (pseudoHeader && headerState != HEADER_STATE_PSEUDO) {
365 headerException = new StreamException(
366 sm.getString("stream.header.unexpectedPseudoHeader", getConnectionId(), getIdAsString(), name),
367 Http2Error.PROTOCOL_ERROR, getIdAsInt());
368 // No need for further processing. The stream will be reset.
369 return;
370 }
371
372 if (headerState == HEADER_STATE_PSEUDO && !pseudoHeader) {
373 headerState = HEADER_STATE_REGULAR;
374 }
375
376 if (headerState == HEADER_STATE_TRAILER && !handler.getProtocol().isTrailerHeaderAllowed(name)) {
377 // Processing trailers and the header is not in the allowed list
378 return;
379 }

Callers

nothing calls this directly

Calls 15

getConnectionIdMethod · 0.95
parseAuthorityMethod · 0.95
compareAuthorityMethod · 0.95
parsePriorityMethod · 0.95
setUrgencyMethod · 0.95
getUrgencyMethod · 0.95
setIncrementalMethod · 0.95
getIncrementalMethod · 0.95
getIdAsStringMethod · 0.80
getIdAsIntMethod · 0.80
charAtMethod · 0.80

Tested by

no test coverage detected