use of org.webpieces.httpparser.api.dto.HttpUri in project webpieces by deanhiller.
the class TestUriParsing method testSlash.
@Test
public void testSlash() {
HttpUri uri = new HttpUri("/");
UrlInfo urlInfo = uri.getUriBreakdown();
Assert.assertEquals(null, urlInfo.getPrefix());
Assert.assertEquals(null, urlInfo.getHost());
Assert.assertEquals(null, urlInfo.getPort());
Assert.assertEquals("/", urlInfo.getFullPath());
}
use of org.webpieces.httpparser.api.dto.HttpUri in project webpieces by deanhiller.
the class HttpParserImpl method parseRequest.
private HttpMessage parseRequest(MementoImpl memento, List<String> lines) {
//remove first line...
String firstLine = lines.remove(0);
String[] firstLinePieces = firstLine.split("\\s+");
if (firstLinePieces.length != 3) {
throw new ParseException("Unable to parse invalid http request due to first line being invalid=" + firstLine + " all Lines=" + lines);
}
HttpRequestMethod method = new HttpRequestMethod(firstLinePieces[0]);
HttpUri uri = new HttpUri(firstLinePieces[1]);
HttpVersion version = parseVersion(firstLinePieces[2], firstLine);
HttpRequestLine httpRequestLine = new HttpRequestLine();
httpRequestLine.setMethod(method);
httpRequestLine.setUri(uri);
httpRequestLine.setVersion(version);
HttpRequest request = new HttpRequest();
request.setRequestLine(httpRequestLine);
parseHeaders(lines, request);
memento.addMessage(request);
return request;
}
use of org.webpieces.httpparser.api.dto.HttpUri in project webpieces by deanhiller.
the class IntegColoradoEdu method createRequest.
private static HttpRequest createRequest(String host) {
// GET / HTTP/1.1
// Host: www.colorado.edu
// User-Agent: curl/7.43.0
// Accept: */*
HttpRequestLine requestLine = new HttpRequestLine();
requestLine.setMethod(KnownHttpMethod.GET);
requestLine.setUri(new HttpUri("/"));
HttpRequest req = new HttpRequest();
req.setRequestLine(requestLine);
req.addHeader(new Header(KnownHeaderName.HOST, host));
req.addHeader(new Header(KnownHeaderName.ACCEPT, "*/*"));
req.addHeader(new Header(KnownHeaderName.USER_AGENT, "webpieces/0.9"));
return req;
}
use of org.webpieces.httpparser.api.dto.HttpUri in project webpieces by deanhiller.
the class TestLesson1BasicRequestResponse method createRequest.
static HttpRequest createRequest(String uri) {
HttpRequestLine requestLine = new HttpRequestLine();
requestLine.setMethod(KnownHttpMethod.GET);
requestLine.setUri(new HttpUri(uri));
HttpRequest req = new HttpRequest();
req.setRequestLine(requestLine);
req.addHeader(new Header(KnownHeaderName.HOST, "yourdomain.com"));
return req;
}
use of org.webpieces.httpparser.api.dto.HttpUri in project webpieces by deanhiller.
the class Requests method createRequest.
public static HttpRequest createRequest(KnownHttpMethod method, String url, boolean isHttps) {
HttpUri httpUri = new HttpUri(url);
HttpRequestLine requestLine = new HttpRequestLine();
requestLine.setMethod(method);
requestLine.setUri(httpUri);
HttpRequest req = new HttpRequest();
req.setRequestLine(requestLine);
req.addHeader(new Header(KnownHeaderName.HOST, "myhost.com"));
return req;
}
Aggregations