Skip to content

Commit

Permalink
Merge pull request #1294 from ashitsalesforce/master
Browse files Browse the repository at this point in the history
set client name and client_id in every server request
  • Loading branch information
ashitsalesforce authored Sep 30, 2024
2 parents 9df9895 + 7b84efb commit ab6fe97
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

Expand All @@ -52,6 +53,7 @@
import org.apache.http.entity.ContentType;
import org.apache.http.entity.InputStreamEntity;

import com.salesforce.dataloader.config.Config;
import com.salesforce.dataloader.exception.HttpClientTransportException;
import com.salesforce.dataloader.util.AppUtil;
import com.sforce.async.AsyncApiException;
Expand Down Expand Up @@ -347,6 +349,14 @@ private OutputStream doConnect(String endpoint,
this.httpMethod.addHeader(name, httpHeaders.get(name));
}
}
Map<String, String> connectorHeaders = currentConfig.getHeaders();
if (connectorHeaders != null) {
for (String name : connectorHeaders.keySet()) {
if (httpHeaders == null || !httpHeaders.containsKey(name)) {
this.httpMethod.addHeader(name, connectorHeaders.get(name));
}
}
}
setAuthAndClientHeadersForHttpMethod();
if (requestInputStream != null) {
ContentType contentType = ContentType.DEFAULT_TEXT;
Expand Down Expand Up @@ -413,6 +423,11 @@ private void setAuthAndClientHeadersForHttpMethod() {
if (userAgentHeaderVal == null) {
this.httpMethod.addHeader(USER_AGENT_HEADER, VersionInfo.info());
}
Header clientIdHeaderVal = this.httpMethod.getFirstHeader("client_id");
if (clientIdHeaderVal == null) {
Config config = Config.getCurrentConfig();
this.httpMethod.addHeader("client_id", config.getString(Config.OAUTH_CLIENTID));
}
}
public static void closeConnections() {
if (currentHttpClient != null) {
Expand Down

0 comments on commit ab6fe97

Please sign in to comment.