### Question:
RtspRequestHeader extends RtspHeader { public static RtspRequestHeader parse(String[] headerLines) throws ParseException, RtspException { Matcher m = requestPattern.matcher(headerLines[0]); if (!m.find()) throw new ParseException("not a valid request line", 0); if (!m.group(3).equalsIgnoreCase("RTSP")) throw new ParseException("unsupported protocol: " + m.group(3), 0); if (!m.group(4).matches("1.0")) throw new RtspException(505, "unsupported RTSP version: " + m.group(4), 0); RtspRequestHeader result = new RtspRequestHeader(m.group(1), m.group(2)); for (int i = 1; i < headerLines.length; i++) { StringBuilder fieldLine = new StringBuilder(headerLines[i]); while (++i < headerLines.length) { if (headerLines[i].length() > 0 && !Character.isWhitespace(headerLines[i].charAt(0))) break; fieldLine.append(headerLines[i].trim()); } Field field = Field.parse(fieldLine.toString()); if (field != null) result.addField(field); i--; } return result; } protected  RtspRequestHeader(String method, String uri);  RtspRequestHeader(String method, String uri, int cseq); String getMethod(); void setMethod(String method); String getUri(); void setUri(String uri); @Override String toString(); static RtspRequestHeader parse(String[] headerLines); static final String METHOD_DESCRIBE; static final String METHOD_OPTIONS; static final String METHOD_PAUSE; static final String METHOD_PLAY; static final String METHOD_SETUP; static final String METHOD_TEARDOWN; static final String METHOD_GET_PARAMETER; }### Answer:
@Test public void testParse() throws Exception { System.out.println("RTSP message request header parse test..."); String[][] lines = new String[][] { { "PLAY /test.sdp RTSP/1.0", "CSeq: 1", "Transport:RTP/AVP;", " unicast;client_port=5000" }, { "test" }, { "OPTIONS * RTP/1.0" }, { "OPTIONS * RTSP/2.0" }, }; int i = 0; RtspRequestHeader rh = RtspRequestHeader.parse(lines[i++]); assertEquals("PLAY", rh.getMethod()); assertEquals("/test.sdp", rh.getUri()); assertEquals(1, rh.getCSeq()); TransportField tf = (TransportField)rh.getField("transport"); assertEquals(5000, (int)tf.getClientPortFrom()); for (; i < lines.length; i++) { try { RtspRequestHeader.parse(lines[i]); fail("request header: \"" + Arrays.toString(lines[i]) + "\" parsed without an exception"); } catch (ParseException ex) { } catch (RtspException ex) { } } }