Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch requests to use GET method when possible. #6

Merged
merged 1 commit into from
Mar 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class B2GetFileInfoRequest extends BaseB2Request {
public B2GetFileInfoRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String fileId) {
super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_GET_FILE_INFO);

this.addProperty(B2RequestProperties.KEY_FILE_ID, fileId);
this.addParameter(B2RequestProperties.KEY_FILE_ID, fileId);
}

/**
Expand All @@ -64,6 +64,6 @@ public B2GetFileInfoRequest(CloseableHttpClient client, B2AuthorizeAccountRespon
* @throws IOException if there was an error communicating with the API service
*/
public B2FileResponse getResponse() throws B2ApiException, IOException {
return new B2FileResponse(EntityUtils.toString(executePost().getEntity()));
return new B2FileResponse(EntityUtils.toString(executeGet().getEntity()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResp
public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, String bucketId, String startFileName, Integer maxFileCount, String prefix, String delimiter) {
super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_FILE_NAMES);

this.addProperty(B2RequestProperties.KEY_BUCKET_ID, bucketId);
this.addParameter(B2RequestProperties.KEY_BUCKET_ID, bucketId);

if(null != startFileName) {
this.addProperty(B2RequestProperties.KEY_START_FILE_NAME, startFileName);
this.addParameter(B2RequestProperties.KEY_START_FILE_NAME, startFileName);
}
if(null != prefix) {
this.addProperty(B2RequestProperties.KEY_PREFIX, prefix);
this.addParameter(B2RequestProperties.KEY_PREFIX, prefix);
}
if(null != delimiter) {
this.addProperty(B2RequestProperties.KEY_DELIMITER, delimiter);
this.addParameter(B2RequestProperties.KEY_DELIMITER, delimiter);
}

this.addProperty(B2RequestProperties.KEY_MAX_FILE_COUNT, maxFileCount);
this.addParameter(B2RequestProperties.KEY_MAX_FILE_COUNT, String.valueOf(maxFileCount));
}

/**
Expand All @@ -107,6 +107,6 @@ public B2ListFileNamesRequest(CloseableHttpClient client, B2AuthorizeAccountResp
* @throws IOException if there was an error communicating with the API service
*/
public B2ListFilesResponse getResponse() throws B2ApiException, IOException {
return new B2ListFilesResponse(EntityUtils.toString(executePost().getEntity()));
return new B2ListFilesResponse(EntityUtils.toString(executeGet().getEntity()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountR
String prefix, String delimiter) {
super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_FILE_VERSIONS);

this.addProperty(B2RequestProperties.KEY_BUCKET_ID, bucketId);
this.addProperty(B2RequestProperties.KEY_MAX_FILE_COUNT, maxFileCount);
this.addParameter(B2RequestProperties.KEY_BUCKET_ID, bucketId);
this.addParameter(B2RequestProperties.KEY_MAX_FILE_COUNT, String.valueOf(maxFileCount));
if(null != startFileName) {
this.addProperty(B2RequestProperties.KEY_START_FILE_NAME, startFileName);
this.addParameter(B2RequestProperties.KEY_START_FILE_NAME, startFileName);
}
if(null != startFileId) {
this.addProperty(B2RequestProperties.KEY_START_FILE_ID, startFileId);
this.addParameter(B2RequestProperties.KEY_START_FILE_ID, startFileId);
}
if(null != prefix) {
this.addProperty(B2RequestProperties.KEY_PREFIX, prefix);
this.addParameter(B2RequestProperties.KEY_PREFIX, prefix);
}
if(null != delimiter) {
this.addProperty(B2RequestProperties.KEY_DELIMITER, delimiter);
this.addParameter(B2RequestProperties.KEY_DELIMITER, delimiter);
}
}

Expand All @@ -116,6 +116,6 @@ public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountR
* @throws IOException if there was an error communicating with the API service
*/
public B2ListFilesResponse getResponse() throws B2ApiException, IOException {
return new B2ListFilesResponse(EntityUtils.toString(executePost().getEntity()));
return new B2ListFilesResponse(EntityUtils.toString(executeGet().getEntity()));
}
}
8 changes: 4 additions & 4 deletions src/main/java/synapticloop/b2/request/B2ListPartsRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public B2ListPartsRequest(CloseableHttpClient client, B2AuthorizeAccountResponse
String fileId, Integer startPartNumber, Integer maxPartCount) {
super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_PARTS);

this.addProperty(B2RequestProperties.KEY_FILE_ID, fileId);
this.addParameter(B2RequestProperties.KEY_FILE_ID, fileId);
if (startPartNumber != null) {
this.addProperty(B2RequestProperties.KEY_START_PART_NUMBER, startPartNumber);
this.addParameter(B2RequestProperties.KEY_START_PART_NUMBER, String.valueOf(startPartNumber));
}
if (startPartNumber != null) {
this.addProperty(B2RequestProperties.KEY_MAX_PART_COUNT, maxPartCount);
this.addParameter(B2RequestProperties.KEY_MAX_PART_COUNT, String.valueOf(maxPartCount));
}
}

public B2ListPartsResponse getResponse() throws B2ApiException, IOException {
return new B2ListPartsResponse(EntityUtils.toString(executePost().getEntity()));
return new B2ListPartsResponse(EntityUtils.toString(executeGet().getEntity()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public B2ListUnfinishedLargeFilesRequest(CloseableHttpClient client, B2Authorize
String bucketId, String startFileId, Integer maxFileCount) {
super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_UNFINISHED_LARGE_FILES);

this.addProperty(B2RequestProperties.KEY_BUCKET_ID, bucketId);
this.addParameter(B2RequestProperties.KEY_BUCKET_ID, bucketId);
if (null != startFileId) {
this.addProperty(B2RequestProperties.KEY_START_FILE_ID, startFileId);
this.addParameter(B2RequestProperties.KEY_START_FILE_ID, startFileId);
}
if (maxFileCount != null) {
this.addProperty(B2RequestProperties.KEY_MAX_FILE_COUNT, maxFileCount);
this.addParameter(B2RequestProperties.KEY_MAX_FILE_COUNT, String.valueOf(maxFileCount));
}
}

public B2ListFilesResponse getResponse() throws B2ApiException, IOException {
return new B2ListFilesResponse(EntityUtils.toString(executePost().getEntity()));
return new B2ListFilesResponse(EntityUtils.toString(executeGet().getEntity()));
}
}