Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/src/main/java/com/predic8/membrane/core/http/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ public Builder url(URIFactory uriFactory, String url) throws URISyntaxException
return this;
}

public Builder uri(String uri) {
req.setUri(uri);
return this;
}

public Builder version(String version) {
req.setVersion(version);
return this;
}

public Builder authorization(String username, String password) {
req.getHeader().setAuthorization(username,password);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.util.Enumeration;

Expand Down Expand Up @@ -111,7 +112,6 @@ protected void writeResponse(Response res) throws Exception {
}

private Request createRequest() throws IOException {
Request srcReq = new Request();

String pathQuery = request.getRequestURI();
if (request.getQueryString() != null)
Expand All @@ -123,13 +123,25 @@ private Request createRequest() throws IOException {
pathQuery = pathQuery.substring(contextPath.length());
}

srcReq.create(
return createRequest(
request.getMethod(),
pathQuery,
request.getProtocol(),
createHeader(),
request.getInputStream());
return srcReq;
}

public Request createRequest(String method, String uri, String protocol, Header header, InputStream in) {
if (!protocol.startsWith("HTTP/"))
throw new RuntimeException("Unknown protocol '" + protocol + "'");

return new Request.Builder()
.method(method)
.uri(uri)
.header(header)
.body(in)
.version(protocol.substring(5))
.build();
}

private Header createHeader() {
Expand Down
Loading