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

FixBug issues 241 #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -5,16 +5,14 @@
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.*;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.StreamSupport;

public abstract class AbstractHttpTransport implements HttpTransport {

Expand All @@ -41,7 +39,7 @@ public HttpResponse makePutRequest(HttpRequest request) {
HttpPut httpPut = new HttpPut(request.getUrl());
addHeadersToRequest(httpPut, request.getHeaders());
if (request.getContent() != null) {
httpPut.setEntity(new StringEntity(request.getContent(), StandardCharsets.UTF_8));
httpPut.setEntity(new StringEntity(request.getContent(), ContentType.APPLICATION_JSON));
} else {
httpPut.setEntity(new ByteArrayEntity(request.getBinaryContent()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public Response<Void> agentSetMaintenance(boolean maintenanceEnabled) {
@Override
public Response<Void> agentSetMaintenance(boolean maintenanceEnabled, String reason) {
UrlParameters maintenanceParameter = new SingleUrlParameters("enable", Boolean.toString(maintenanceEnabled));
UrlParameters reasonParamenter = reason != null ? new SingleUrlParameters("reason", reason) : null;
UrlParameters reasonParameter = reason != null ? new SingleUrlParameters("reason", reason) : null;

HttpResponse httpResponse = rawClient.makePutRequest("/v1/agent/maintenance", "", maintenanceParameter, reasonParamenter);
HttpResponse httpResponse = rawClient.makePutRequest("/v1/agent/maintenance", "", maintenanceParameter, reasonParameter);

if (httpResponse.getStatusCode() == 200) {
return new Response<Void>(null, httpResponse);
Expand Down