Parses values out of the header text.

@param header header text
777616
private void parse(String header)
   {
      ArrayList<String> list = new ArrayList<String>(4);
      StringBuilder sb = new StringBuilder();
      int index = 1;
      while (index < header.length())
      {
         char c = header.charAt(index++);
         if (Character.isDigit(c))
         {
            sb.append(c);
         }
         else
         {
            if (sb.length() != 0)
            {
               list.add(sb.toString());
               sb.setLength(0);
            }
         }
      }

      if (sb.length() != 0)
      {
         list.add(sb.toString());
      }

      m_id = list.get(0);
      m_sequence = Integer.parseInt(list.get(1));
      m_type = Integer.valueOf(list.get(2));
      if (list.size() > 3)
      {
         m_subtype = Integer.parseInt(list.get(3));
      }
   }
757779
private String getSimpleHeaderValue(String header, HttpResponse httpResponse, boolean first) {
    if (StringUtils.isBlank(header)) {
      return StringUtils.EMPTY;
    }

    Header h;
    if (first) {
      h = httpResponse.getFirstHeader(header);
    } else {
      h = httpResponse.getLastHeader(header);
    }
    if (h == null) {
      return null;
    }
    return h.getValue();
  }
937514
private void parseHeaders(ReadStream s) throws IOException
  {
    int version = version();

    if (version < HTTP_1_0) {
      return;
    }

    if (version < HTTP_1_1) {
      killKeepalive("http client version less than 1.1: " + version);
    }

    byte []readBuffer = s.buffer();
    int readOffset = s.offset();
    int readLength = s.length();

    char []headerBuffer = _headerBuffer;
    headerBuffer[0] = 'z';
    int headerOffset = 1;
    _headerSize = 0;
    
    int readTail = readLength;
    if (headerBuffer.length - 1 < readTail - readOffset) {
      readTail = headerBuffer.length - 1;
    }

    boolean isLogFine = log.isLoggable(Level.FINE);

    while (true) {
      int ch;

      int keyOffset = headerOffset;

      // scan the key
      while (true) {
        if (readTail <= readOffset) {
          if ((readTail = fillHeaderTail(s, readOffset, headerOffset)) <= 0) {
            return;
          }

          readOffset = s.offset();
          headerOffset = _headerLength;
          headerBuffer = _headerBuffer;
        }

        ch = readBuffer[readOffset++];

        if (ch == '\n') {
          s.offset(readOffset);
          return;
        }
        else if (ch == ':') {
          break;
        }

        headerBuffer[headerOffset++] = (char) ch;
      }

      // strip trailing whitespace from key
      while (headerBuffer[headerOffset - 1] == ' ') {
        headerOffset--;
      }
      
      int keyLength = headerOffset - keyOffset;

      // skip whitespace
      do {
        if (readTail <= readOffset) {
          if ((readTail = fillHeaderTail(s, readOffset, headerOffset)) <= 0) {
            return;
          }

          readOffset = s.offset();
          headerOffset = _headerLength;
          headerBuffer = _headerBuffer;
        }
        
        ch = readBuffer[readOffset++];
      } while (ch == ' ' || ch == '\t');

      int valueOffset = headerOffset;

      // scan the value
      while (true) {
        if (readTail <= readOffset) {
          if ((readTail = fillHeaderTail(s, readOffset, headerOffset)) <= 0) {
            break;
          }

          readOffset = s.offset();
          headerOffset = _headerLength;
          headerBuffer = _headerBuffer;
        }

        if (ch == '\n') {
          int ch1 = readBuffer[readOffset];

          if (ch1 == ' ' || ch1 == '\t') {
            ch = ' ';
            readOffset++;

            if (headerBuffer[headerOffset - 1] == '\r') {
              headerOffset--;
            }
          }
          else
            break;
        }

        headerBuffer[headerOffset++] = (char) ch;

        ch = readBuffer[readOffset++];
      }

      while (headerBuffer[headerOffset - 1] <= ' ') {
        headerOffset--;
      }
      
      int headerSize = _headerSize;
      
      CharSegment []headerKeys = _headerKeys;
      CharSegment []headerValues = _headerValues;

      if (headerKeys.length <= headerSize) {
        _headerLength = headerOffset;
        extendHeaderBuffers();
        
        headerBuffer = _headerBuffer;
        headerKeys = _headerKeys;
        headerValues = _headerValues;
      }

      headerKeys[headerSize].init(headerBuffer, keyOffset, keyLength);

      int valueLength = headerOffset - valueOffset;
      headerValues[headerSize].init(headerBuffer, valueOffset, valueLength);

      if (isLogFine) {
        log.fine(headerKeys[headerSize] + ": " + headerValues[headerSize]
                 + " (" + dbgId() + ")");
      }

      if (addHeaderInt(headerBuffer, keyOffset, keyLength,
                       headerValues[headerSize])) {
        headerSize++;
      }

      _headerSize = headerSize;
    }
  }
606562
public void setHeaderValue(@NotNull String headerValue) {
        if (StringUtils.isBlank(headerValue)) {
            throw new IllegalArgumentException("Parameter 'headerValue' cannot be blank." +
                    " If you want to disable this header invoke disable() method.");
        }
        this.headerValue = headerValue;
    }
1110619
public void parse(byte[] data) throws ParseException {
        Text text = new Text();
        text.strain(data, 0, data.length);
        init(text);
    }
137773
def parse_headers(self, req, name, field):
        """"""
        return get_value(req.headers, name, field)
1372671
public static Locale parseLocale( final String header )
    {
        //        String header = "en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2";

        if ( header == null || header.trim()
                                     .length() < 1 )
        {
            return Locale.getDefault( Category.FORMAT );
        }

        final Map<Double, String> prefs = parseQualityHeader( header );

        final List<Double> sortedKeys = new ArrayList<Double>( prefs.keySet() );
        Collections.sort( sortedKeys );
        Collections.reverse( sortedKeys );

        final Locale[] available = Locale.getAvailableLocales();
        Locale result = null;
        for ( final Double key : sortedKeys )
        {
            final String[] parts = prefs.get( key )
                                        .split( "_" );

            for ( final Locale l : available )
            {
                if ( !parts[0].equals( l.getISO3Language() ) )
                {
                    continue;
                }

                if ( parts.length > 1 && !parts[1].equals( l.getISO3Country() ) )
                {
                    continue;
                }

                if ( parts.length > 2 && !parts[2].equals( l.getVariant() ) )
                {
                    continue;
                }

                result = l;
            }
        }

        return result == null ? Locale.getDefault( Category.FORMAT ) : result;
    }
678639
@SuppressWarnings("unused")
    final void handleHeaderValue(ByteBuffer buffer, ResponseParseState state, HttpResponseBuilder builder) {
        StringBuilder stringBuilder = state.stringBuilder;
        if (stringBuilder == null) {
            stringBuilder = new StringBuilder();
            state.parseState = 0;
        }

        int parseState = state.parseState;
        while (buffer.hasRemaining()) {
            final byte next = buffer.get();
            switch (parseState) {
                case NORMAL: {
                    if (next == '\r') {
                        parseState = BEGIN_LINE_END;
                    } else if (next == '\n') {
                        parseState = LINE_END;
                    } else if (next == ' ' || next == '\t') {
                        parseState = WHITESPACE;
                    } else {
                        stringBuilder.append((char) next);
                    }
                    break;
                }
                case WHITESPACE: {
                    if (next == '\r') {
                        parseState = BEGIN_LINE_END;
                    } else if (next == '\n') {
                        parseState = LINE_END;
                    } else if (next == ' ' || next == '\t') {
                    } else {
                        if (stringBuilder.length() > 0) {
                            stringBuilder.append(' ');
                        }
                        stringBuilder.append((char) next);
                        parseState = NORMAL;
                    }
                    break;
                }
                case LINE_END:
                case BEGIN_LINE_END: {
                    if (next == '\n' && parseState == BEGIN_LINE_END) {
                        parseState = LINE_END;
                    } else if (next == '\t' ||
                            next == ' ') {
                        //this is a continuation
                        parseState = WHITESPACE;
                    } else {
                        //we have a header
                        HttpString nextStandardHeader = state.nextHeader;
                        String headerValue = stringBuilder.toString();

                        //TODO: we need to decode this according to RFC-2047 if we have seen a =? symbol
                        builder.getResponseHeaders().add(nextStandardHeader, headerValue);

                        state.nextHeader = null;

                        state.leftOver = next;
                        state.stringBuilder.setLength(0);
                        if (next == '\r') {
                            parseState = AWAIT_DATA_END;
                        } else {
                            state.state = ResponseParseState.HEADER;
                            state.parseState = 0;
                            return;
                        }
                    }
                    break;
                }
                case AWAIT_DATA_END: {
                    state.state = ResponseParseState.PARSE_COMPLETE;
                    return;
                }
            }
        }
        //we only write to the state if we did not finish parsing
        state.parseState = parseState;
    }
288211
private function parseHeader($header)
    {
        $res = preg_match_all('/(?:[^,"]*+(?:"[^"]*+")?)+[^,"]*+/', $header, $matches);

        if (!$res) {
            throw new InvalidHeader(sprintf('Failed to parse accept header: "%s"', $header));
        }

        return array_values(array_filter(array_map('trim', $matches[0])));
    }
664118
void parseHeader(String header, Set<String> packages) {
        if (header != null && header.length() > 0) {
            List<String> splitPackages = new ArrayList<String>();
            // We can't just split() on commas, because there may be things in quotes, like uses clauses
            int lastIndex = 0;
            boolean inQuotedSection = false;
            int i = 0;
            for (i = 0; i < header.length(); i++) {
                if ((header.charAt(i) == ',') && !(inQuotedSection)) {
                    String packagePlusAttributesAndDirectives = header.substring(lastIndex, i);
                    lastIndex = i + 1;
                    splitPackages.add(packagePlusAttributesAndDirectives);
                } else if (header.charAt(i) == '"') {
                    inQuotedSection = !inQuotedSection;
                }
            }
            // Add the last string
            splitPackages.add(header.substring(lastIndex, i));

            // Now go through and handle the attributes

            for (String packagePlusAttributesAndDirectives : splitPackages) {
                String[] bits = packagePlusAttributesAndDirectives.split(";");
                // We could also process ibm-api-type and other declarations here to get better information if we need it
                packages.add(bits[0]);

            }
        }
    }
7499
protected void readHeader(ByteBuffer buffer) {
    super.readHeader(buffer);
    if (this.responseStatus == ResponseStatus.NO_ERROR) {
      this.decodeStatus = BinaryDecodeStatus.DONE;
    }
  }
160277
def parse_multi_value_header(header_str):
    """"""
    parsed_parts = []
    if header_str:
        parts = header_str.split(',')
        for part in parts:
            match = re.search('\s*(W/)?\"?([^"]*)\"?\s*', part)
            if match is not None:
                parsed_parts.append(match.group(2))
    return parsed_parts
912550
public String getHeader(String header) {
        if (headers == null) {
            return null;
        }
        return headers.get(header);
    }
1064684
public static void header(Header header, String value) {
        Objects.requireNonNull(header, Required.HEADER.toString());
        
        Map<Header, String> newHeaders = new EnumMap<>(headers);
        newHeaders.put(header, value);
        headers = newHeaders;
    }
1018090
@Override
  public void header(String key, String value)
  {
    _is.header(key, value);
  }
674266
private void parseHeaderValidation(Map<Object, Object> props) {
        Object value = props.get(HttpConfigConstants.PROPNAME_HEADER_VALIDATION);
        if (null != value) {
            this.bHeaderValidation = convertBoolean(value);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Config: header validation is " + isHeaderValidationEnabled());
            }
        }
    }
413832
public static Header[] parseHttpHeaders(final String headers) {
    if (headers == null || headers.length() == 0) {
      return null;
    }

    final String[] headerArray = headers.split(HEADER_ELEMENT_DELIMITER);
    final List<Header> headerList = new ArrayList<>(headerArray.length);
    for (int i = 0; i < headerArray.length; i++) {
      final String headerPair = headerArray[i];
      final int index = headerPair.indexOf(HEADER_NAME_VALUE_DELIMITER);
      if (index != -1) {
        headerList.add(new BasicHeader(headerPair.substring(0, index),
            headerPair.substring(index + 1)));
      }

    }
    return headerList.toArray(new BasicHeader[0]);
  }