List of usage examples for org.apache.http.message LineParser parseProtocolVersion
ProtocolVersion parseProtocolVersion(CharArrayBuffer charArrayBuffer, ParserCursor parserCursor)
throws ParseException;
From source file:com.subgraph.vega.ui.httpeditor.parser.HttpRequestParser.java
/** * Read and parse the request line./* w w w . j a v a 2 s . c o m*/ * * @param parser HC LineParser. * @param builder HTTP request builder. * @param buf * @param bufCursor * @return * @throws URISyntaxException */ private int parseRequestLine(final LineParser parser, final IHttpRequestBuilder builder, final CharArrayBuffer buf, final ParserCursor bufCursor) throws URISyntaxException { final CharArrayBuffer lnBuf = new CharArrayBuffer(0); if (readLine(buf, bufCursor, lnBuf) < 1) { // no data! return -1; } final ParserCursor lnCursor = new ParserCursor(0, lnBuf.length()); String method, uri; ProtocolVersion version; if ((method = nextWord(lnBuf, lnCursor)) != null) { if ((uri = nextWord(lnBuf, lnCursor)) != null) { try { version = parser.parseProtocolVersion(lnBuf, lnCursor); } catch (ParseException e) { // treat the unparseable version as HTTP/1.1 version = new ProtocolVersion("HTTP", 1, 1); } ; } else { uri = ""; version = null;//new ProtocolVersion("HTTP", 0, 9); } } else { method = lnBuf.toString(); uri = ""; version = null;//new ProtocolVersion("HTTP", 0, 9); } builder.setMethod(method); builder.setFromUri(new URI(uri)); builder.setProtocolVersion(version); return 0; }