Process Content Header frames
334325
def _process_content_header(self, channel, payload):
        
        partial = self.partial_messages[channel]
        partial.add_header(payload)

        if partial.complete:
            #
            # a bodyless message, we're done
            #
            self.queue.put((channel, partial.method_sig, partial.args, partial.msg))
            del self.partial_messages[channel]
            self.expected_types[channel] = 1
        else:
            #
            # wait for the content-body
            #
            self.expected_types[channel] = 3
548671
function processHeader($lastLine = "\r\n") {
      $headers = array();
      $finished = false;

      while ( (!$finished) && (!feof($this->socket)) ) {
        $str = fgets($this->socket, 1024);
        $finished = ($str == $lastLine);
        if (!$finished) {
          list($hdr, $value) = preg_split('/: /', $str, 2);
// nasty workaround broken multiple same headers (eg. Set-Cookie headers) @FIXME
          if (isset($headers[$hdr])) {
            $headers[$hdr] .= '; ' . trim($value);
          } else {
            $headers[$hdr] = trim($value);
          }
        }
      }

      return $headers;
    }
1337162
def _createDataStructure(self, content):
        
        aux = {}
        aux["headers"] = {}
        aux["content"] = ""
        for i, line in enumerate(content.splitlines()):
            if i == 0:
                aux["procotol"] = line.split()[0]
                aux["code"] = line.split()[1]
            elif line != "":
                header =  line.split(": ")[0]
                aux["headers"][header] = line[line.find(": ")+2:]
            else:
                aux["content"] += self._rebuildHTMLContent(content.splitlines()[i+1:])
                
                # TO-DO: Perform additional processing of the HTML
                
                break  
        return aux
168585
public void processCompleteFrame() throws Http2Exception {
        Frame currentFrame = getCurrentFrame();

        boolean frameSizeError = false;
        try {
            currentFrame.processPayload(this);
        } catch (Http2Exception e) {
            // If we get an error here, it should be safe to assume that this frame doesn't have the expected byte count,
            // which must be treated as an error of type FRAME_SIZE_ERROR.  If we're processing a DATA or PRIORITY frame, then
            // we can treat the error as a stream error rather than a connection error.
            if (!e.isConnectionError()) {
                frameSizeError = true;
            } else {
                // this is a connection error; we need to send a GOAWAY on the connection
                throw e;
            }
        } catch (Exception e) {
            throw new ProtocolException("Error processing the payload for " + currentFrame.getFrameType()
                                        + " frame on stream " + currentFrame.getStreamId());
        }

        // call the stream processor to process this stream. For now, don't return from here until the
        // frame has been fully processed.
        int streamId = currentFrame.getStreamId();
        H2StreamProcessor stream = muxLink.getStream(streamId);

        if (stream == null) {
            if ((streamId != 0) && (streamId % 2 == 0)) {
                if (currentFrame.getFrameType().equals(FrameTypes.PRIORITY)) {
                    // ignore PRIORITY frames in any state
                    return;
                } else if (currentFrame.getFrameType().equals(FrameTypes.RST_STREAM) && streamId < muxLink.getHighestClientStreamId()) {
                    // tolerate RST_STREAM frames that are sent on closed push streams
                    return;
                } else {
                    throw new ProtocolException("Cannot start a stream from the client with an even numbered ID. stream-id: " + streamId);
                }
            } else {
                stream = startNewInboundSession(streamId);
            }
        }
        if (frameSizeError) {
            currentFrame = new FrameRstStream(streamId, 4, (byte) 0, false, FrameDirection.READ);
            ((FrameRstStream) currentFrame).setErrorCode(Constants.FRAME_SIZE_ERROR);
        }

        stream.processNextFrame(currentFrame, Direction.READ_IN);
    }
1339246
def parse_content_type(headers: MutableMapping) -> Tuple[Optional[str], str]:
    
    content_type = headers.get("content-type")
    if not content_type:
        return None, "utf-8"
    else:
        type_, parameters = cgi.parse_header(content_type)
        encoding = parameters.get("charset", "utf-8")
        return type_, encoding
390259
def _pipe(content):
    
    response = _data_frame(content).to_csv(index=False,sep='|')
    return response
729420
def render_headers(self):
        
        lines = []

        sort_keys = ['Content-Disposition', 'Content-Type', 'Content-Location']
        for sort_key in sort_keys:
            if self.headers.get(sort_key, False):
                lines.append('%s: %s' % (sort_key, self.headers[sort_key]))

        for header_name, header_value in self.headers.items():
            if header_name not in sort_keys:
                if header_value:
                    lines.append('%s: %s' % (header_name, header_value))

        lines.append('\r\n')
        return '\r\n'.join(lines)
339768
def getouterframes(frame, context=1):
    """"""
    framelist = []
    while frame:
        framelist.append((frame,) + getframeinfo(frame, context))
        frame = frame.f_back
    return framelist
956163
def _headers(self, others={}):
        """"""
        headers = {
            'Content-Type': 'application/json'
        }

        for p in others.keys():
            headers[p] = others[p]
        return headers
416669
def process_data(self, file_info):
        """"""
        if self._is_already_processed(file_info):
            self.log.debug("Content file already processed '%s'", str(file_info))
            self.fire(events.FilteredFile(file_info))
            self.fire(events.FileInfoAlreadyProcessed(file_info))
        else:
            return file_info
        return None
281642
def ProcessContent(self, strip_expansion=False):
    """"""
    self._ParseFile()
    if strip_expansion:
      # Without a collection the expansions become blank, removing them.
      collection = None
    else:
      collection = MacroCollection()
    for section in self._sections:
      section.BindMacroCollection(collection)
    result = ''
    for section in self._sections:
      result += section.text
    self._processed_content = result
19871
def content_location(self) -> Optional[UnstructuredHeader]:
        """"""
        try:
            return cast(UnstructuredHeader, self[b'content-location'][0])
        except (KeyError, IndexError):
            return None
45353
function getHeaderContent(tokens, type, markup) {
  if (tokens[1].children.length === 0) {
    tokens[1].children.push(getEmptyText());
  } else if (tokens[1].children[0].type !== 'text') {
    tokens[1].children.unshift(getEmptyText());
  }
  const content = changeText(tokens[1].children, markup);
  return {
    type,
    content,
    length: getTokensLength(content)
  };
}
472422
function(data, escapeHeaderValues) {
    const onFrame = jasmine.createSpy('onFrame');
    const onIncomingPing = jasmine.createSpy('onIncomingPing');
    const parser = new StompJs.Parser(onFrame, onIncomingPing);

    parser.parseChunk(data);

    const rawFrame = onFrame.calls.first().args[0];
    return StompJs.FrameImpl.fromRawFrame(rawFrame, escapeHeaderValues);
  }
1258218
private static void onHeadersRead(ChannelHandlerContext ctx, Http2HeadersFrame headers)
            throws Exception {
        if (headers.isEndStream()) {
            ByteBuf content = ctx.alloc().buffer();
            content.writeBytes(RESPONSE_BYTES.duplicate());
            ByteBufUtil.writeAscii(content, " - via HTTP/2");
            sendResponse(ctx, content);
        }
    }
1308236
private void processCompleteHeaders(boolean isPush) throws CompressionException, ProtocolException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "processCompleteHeaders entry: stream " + myID);
        }
        if (this.headerBlock != null) {
            //Leave this to maintain current functionality, but passing a buffer
            //down to the channel is not necessary. H2 Headers will be stored in the H2
            //inbound link wrap.
            WsByteBufferPoolManager bufManager = HttpDispatcher.getBufferManager();
            WsByteBuffer buf = bufManager.allocate(getByteCount(headerBlock));

            int firstBlockLength = headerBlock.get(0).length;
            for (byte[] byteArray : headerBlock) {
                buf.put(byteArray);
            }
            buf.flip();
            headerBlock = null;

            //Get ready to decode headers
            boolean isFirstLineComplete = false;
            HashMap<String, String> pseudoHeaders = new HashMap<String, String>();
            ArrayList<H2HeaderField> headers = new ArrayList<H2HeaderField>();
            H2HeaderField current = null;
            boolean isFirstHeaderBlock;
            boolean isFirstHeader = true;
            boolean processTrailerHeaders = headersCompleted;

            //Decode headers until we reach the end of the buffer
            while (buf.hasRemaining()) {
                isFirstHeaderBlock = buf.position() < firstBlockLength;
                try {
                    current = (H2Headers.decodeHeader(buf, this.muxLink.getReadTable(), isFirstHeader && isFirstHeaderBlock,
                                                      processTrailerHeaders && !isPush, this.muxLink.getLocalConnectionSettings()));
                } catch (Http2Exception e) {
                    buf.release();
                    throw e;
                }
                if (current == null) {
                    // processed a dynamic table size update; go to the next header
                    continue;
                }
                isFirstHeader = false;
                if (!isFirstLineComplete) {
                    //Is this a Pseudo-Header?
                    if (current.getName().startsWith(":")) {
                        //Verify if this is a valid pseudo-header. In the case that this pseudo-header had
                        //already been decoded (two pseudo-headers with same name), throw a decompression
                        //exception and invalidate the table.
                        if (pseudoHeaders.get(current.getName()) != null) {
                            this.muxLink.getReadTable().setDynamicTableValidity(false);
                            buf.release();
                            throw new CompressionException("Invalid pseudo-header for decompression context: " + current.toString());
                        }
                        pseudoHeaders.put(current.getName(), current.getValue());
                    }
                    //If it doesn't start with colon, it is a regular header
                    //so mark this as the beginning of the parsing headers
                    //state and try to set the decoded first line.
                    else {
                        isFirstLineComplete = true;
                        if (H2Headers.getContentLengthValue(current) > -1) {
                            expectedContentLength = H2Headers.getContentLengthValue(current);
                        }
                        headers.add(current);
                    }
                } else {
                    //If header starts with ':' throw error
                    if (current.getName().startsWith(":")) {
                        this.muxLink.getReadTable().setDynamicTableValidity(false);
                        buf.release();
                        throw new CompressionException("Invalid pseudo-header decoded: all pseudo-headers must appear " +
                                                       "in the header block before regular header fields.");
                    }
                    if (H2Headers.getContentLengthValue(current) > -1) {
                        expectedContentLength = H2Headers.getContentLengthValue(current);
                    }
                    headers.add(current);
                }
            }
            buf.release();
            // only set headers on the link once
            if ((isPush || !processTrailerHeaders) && h2HttpInboundLinkWrap.getHeadersLength() == 0) {
                if (!isValidH2Request(pseudoHeaders)) {
                    muxLink.setContinuationExpected(false);
                    muxLink.setWriteContinuationExpected(false);
                    ProtocolException e = new ProtocolException("An invalid request was received on stream-id: " + myID);
                    e.setConnectionError(false); // mark this as a stream error so we'll generate an RST_STREAM
                    throw e;
                }
                if (pseudoHeaders.get(HpackConstants.AUTHORITY) != null) {
                    muxLink.setAuthority(pseudoHeaders.get(HpackConstants.AUTHORITY));
                }
                //Add all decoded pseudo-headers and headers
                this.h2HttpInboundLinkWrap.setReadHeaders(headers);
                this.h2HttpInboundLinkWrap.setReadPseudoHeaders(pseudoHeaders);
            }
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "processCompleteHeaders no header block set: stream " + myID);
            }
        }
    }
655902
def _parse_content_type_header(header):
    

    tokens = header.split(';')
    content_type, params = tokens[0].strip(), tokens[1:]
    params_dict = {}
    items_to_strip = "\"' "

    for param in params:
        param = param.strip()
        if param:
            key, value = param, True
            index_of_equals = param.find("=")
            if index_of_equals != -1:
                key = param[:index_of_equals].strip(items_to_strip)
                value = param[index_of_equals + 1:].strip(items_to_strip)
            params_dict[key.lower()] = value
    return content_type, params_dict