Skip to content
Closed
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 src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ public URL getRequestUrl() {
return baseRequest.getRequestUrl();
}

/**
* Gets the request URL
*
* @return the request URL
*/
@Override
public URL getBaseRequestUrl() {
return baseRequest.getBaseRequestUrl();
}

/**
* Gets the HTTP method
*
Expand Down
37 changes: 28 additions & 9 deletions src/main/java/com/microsoft/graph/http/BaseRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public abstract class BaseRequest implements IHttpRequest {
/**
* The URL for this request
*/
private final String requestUrl;
private final String baseRequestUrl;

/**
* The backing client for this request
Expand Down Expand Up @@ -128,16 +128,16 @@ public abstract class BaseRequest implements IHttpRequest {
/**
* Creates the request
*
* @param requestUrl the URL to make the request against
* @param client the client which can issue the request
* @param options the options for this request
* @param responseClass the class for the response
* @param baseRequestUrl the URL to make the request against
* @param client the client which can issue the request
* @param options the options for this request
* @param responseClass the class for the response
*/
public BaseRequest(final String requestUrl,
public BaseRequest(final String baseRequestUrl,
final IBaseClient client,
final List<? extends Option> options,
final Class<?> responseClass) {
this.requestUrl = requestUrl;
this.baseRequestUrl = baseRequestUrl;
this.client = client;
this.responseClass = responseClass;

Expand Down Expand Up @@ -191,8 +191,27 @@ public URL getRequestUrl() {
return null;
}

/**
* Gets the base request URL
*
* @return the base request URL
*/
@Override
public URL getBaseRequestUrl() {
try {
return new URL(this.baseRequestUrl);
} catch (final MalformedURLException e) {
if (this instanceof CustomRequest) {
this.getClient().getLogger().logError("Invalid custom URL: " + this.baseRequestUrl, e);
} else {
throw new ClientException("Invalid URL: " + this.baseRequestUrl, e);
}
}
return null;
}

private String addFunctionParameters() {
final StringBuilder requestUrl = new StringBuilder(this.requestUrl);
final StringBuilder requestUrl = new StringBuilder(this.baseRequestUrl);

if (!getFunctionOptions().isEmpty()) {
requestUrl.append("(");
Expand Down Expand Up @@ -382,7 +401,7 @@ public Class<?> getResponseType() {
return responseClass;
}

/**
/**
* Sets the max redirects
*
* @param maxRedirects Max redirects that a request can take
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/microsoft/graph/http/BaseStreamRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ public URL getRequestUrl() {
return baseRequest.getRequestUrl();
}

/**
* Gets the request URL
*
* @return the request URL
*/
@Override
public URL getBaseRequestUrl() {
return baseRequest.getBaseRequestUrl();
}

/**
* Gets the HTTP method
*
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/microsoft/graph/http/IHttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
*/
public interface IHttpRequest {

/**
* Gets the base request URL
*
* @return the base request URL
*/
URL getBaseRequestUrl();

/**
* Gets the request URL
*
Expand Down Expand Up @@ -84,7 +91,7 @@ public interface IHttpRequest {
* @return the value of useCaches
*/
boolean getUseCaches();

/**
* Sets the max redirects
*
Expand Down Expand Up @@ -155,4 +162,3 @@ public interface IHttpRequest {
*/
long getDelay();
}

9 changes: 9 additions & 0 deletions src/test/java/com/microsoft/graph/http/MockHttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public URL getRequestUrl() {
}
}

@Override
public URL getBaseRequestUrl() {
try {
return new URL("http://localhost");
} catch (final MalformedURLException ex) {
throw new ClientException("Invalid URL", ex);
}
}

@Override
public HttpMethod getHttpMethod() {
return mHttpMethod;
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/microsoft/graph/http/MockRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public URL getRequestUrl() {
return null;
}

@Override
public URL getBaseRequestUrl() {
try {
return new URL("http://localhost");
} catch (final MalformedURLException ignored) {
}
return null;
}

@Override
public HttpMethod getHttpMethod() {
return HttpMethod.GET;
Expand Down