| 202 | } |
| 203 | |
| 204 | private WebRequest parseRequest(final String request) { |
| 205 | final int firstSpace = request.indexOf(' '); |
| 206 | final int secondSpace = request.indexOf(' ', firstSpace + 1); |
| 207 | |
| 208 | HttpMethod submitMethod = HttpMethod.GET; |
| 209 | final String methodText = request.substring(0, firstSpace); |
| 210 | if ("OPTIONS".equalsIgnoreCase(methodText)) { |
| 211 | submitMethod = HttpMethod.OPTIONS; |
| 212 | } |
| 213 | else if ("POST".equalsIgnoreCase(methodText)) { |
| 214 | submitMethod = HttpMethod.POST; |
| 215 | } |
| 216 | |
| 217 | final String requestedPath = request.substring(firstSpace + 1, secondSpace); |
| 218 | if ("/favicon.ico".equals(requestedPath)) { |
| 219 | LOG.debug("Skipping /favicon.ico"); |
| 220 | return null; |
| 221 | } |
| 222 | try { |
| 223 | final URL url = new URL("http://localhost:" + port_ + requestedPath); |
| 224 | lastRequest_ = request; |
| 225 | return new WebRequest(url, submitMethod); |
| 226 | } |
| 227 | catch (final MalformedURLException e) { |
| 228 | LOG.error(e); |
| 229 | return null; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * @return the last received request |