How to parse first line of HTTP Get Request in java? -
i wondering if there quick way parse first line of http request grab directory information? example, if have: /test.txt http/1.1, easiest way test.txt or whatever request might be. file might change hard coding out.
is string.split() easiest way. if best way split be. can't split "/", because there more 1 need. possible split grab after first "/" , stop @ first space. thanks.
edit:
would better remove , http/1.1 since won't need them, , grab else?
3.1.1. request line
a request-line begins method token, followed single space (sp), request-target, single space (sp), protocol version, , ends crlf.
request-line = method sp request-target sp http-version crlf
source: http://tools.ietf.org/html/rfc7230
your method fine. remove method
, http-version
:
string requesturi = firstlinestr.substring(firstlinestr.indexof(' ')+1, firstlinestr.lastindexof(' '));
Comments
Post a Comment