Source:
protected Registration requestRegistration(String agentHostName, AgentAutoRegistrationProperties agentAutoRegisterProperties) throws IOException, ClassNotFoundException { if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("[Agent Registration] Using URL %s to register.", serverUrl)); } String agentWorkDir = systemEnvironment.resolveAgentWorkingDirectory(new File(".")).getAbsolutePath(); HttpRequestBase postMethod = (HttpRequestBase) RequestBuilder.post(serverUrl) .addParameter("hostname", agentHostName) .addParameter("uuid", agentRegistry.uuid()) .addParameter("location", agentWorkDir) .addParameter("usablespace", String.valueOf(AgentRuntimeInfo.usableSpace(agentWorkDir))) .addParameter("operatingSystem", new SystemEnvironment().getOperatingSystemCompleteName()) .addParameter("agentAutoRegisterKey", agentAutoRegisterProperties.agentAutoRegisterKey()) .addParameter("agentAutoRegisterResources", agentAutoRegisterProperties.agentAutoRegisterResources()) .addParameter("agentAutoRegisterEnvironments", agentAutoRegisterProperties.agentAutoRegisterEnvironments()) .addParameter("agentAutoRegisterHostname", agentAutoRegisterProperties.agentAutoRegisterHostname()) .addParameter("elasticAgentId", agentAutoRegisterProperties.agentAutoRegisterElasticAgentId()) .addParameter("elasticPluginId", agentAutoRegisterProperties.agentAutoRegisterElasticPluginId()) .build(); try { CloseableHttpResponse response = httpClient.execute(postMethod); try (InputStream is = response.getEntity() == null ? new NullInputStream(0) : response.getEntity().getContent()) { return readResponse(is); } } finally { postMethod.releaseConnection(); } }

Target:
protected Registration requestRegistration(String agentHostName, AgentAutoRegistrationProperties agentAutoRegisterProperties) throws IOException, ClassNotFoundException { if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("[Agent Registration] Using URL %s to register.", serverUrl)); } String agentWorkDir = systemEnvironment.resolveAgentWorkingDirectory().getAbsolutePath(); HttpRequestBase postMethod = (HttpRequestBase) RequestBuilder.post(serverUrl) .addParameter("hostname", agentHostName) .addParameter("uuid", agentRegistry.uuid()) .addParameter("location", agentWorkDir) .addParameter("usablespace", String.valueOf(AgentRuntimeInfo.usableSpace(agentWorkDir))) .addParameter("operatingSystem", new SystemEnvironment().getOperatingSystemCompleteName()) .addParameter("agentAutoRegisterKey", agentAutoRegisterProperties.agentAutoRegisterKey()) .addParameter("agentAutoRegisterResources", agentAutoRegisterProperties.agentAutoRegisterResources()) .addParameter("agentAutoRegisterEnvironments", agentAutoRegisterProperties.agentAutoRegisterEnvironments()) .addParameter("agentAutoRegisterHostname", agentAutoRegisterProperties.agentAutoRegisterHostname()) .addParameter("elasticAgentId", agentAutoRegisterProperties.agentAutoRegisterElasticAgentId()) .addParameter("elasticPluginId", agentAutoRegisterProperties.agentAutoRegisterElasticPluginId()) .build(); try { CloseableHttpResponse response = httpClient.execute(postMethod); if (getStatusCode(response) == SC_ACCEPTED) { LOGGER.debug("The server has accepted the registration request."); return Registration.createNullPrivateKeyEntry(); } try (InputStream is = response.getEntity() == null ? new NullInputStream(0) : response.getEntity().getContent()) { String responseBody = IOUtils.toString(is, StandardCharsets.UTF_8); if (getStatusCode(response) == 200) { LOGGER.info("This agent is now approved by the server."); return readResponse(responseBody); } else { LOGGER.warn(String.format("The server sent a response that we could not understand. The HTTP status was %s. The response body was:\n%s", response.getStatusLine(), responseBody)); return Registration.createNullPrivateKeyEntry(); } } } finally { postMethod.releaseConnection(); } }