Skip to content
Merged
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
22 changes: 22 additions & 0 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/GitLabApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class GitLabApiClient implements AutoCloseable {
private Long sudoAsId;
private Integer connectTimeout;
private Integer readTimeout;
private String userAgentHeader;

/**
* Construct an instance to communicate with a GitLab API server using the specified GitLab API version,
Expand Down Expand Up @@ -871,6 +872,9 @@ protected Invocation.Builder invocation(URL url, MultivaluedMap<String, String>
} else {
builder = builder.header(authHeader, authValue).accept(accept);
}
if (userAgentHeader != null) {
builder.header("User-Agent", userAgentHeader);
}

// If sudo as ID is set add the Sudo header
if (sudoAsId != null && sudoAsId.intValue() > 0) builder = builder.header(SUDO_HEADER, sudoAsId);
Expand Down Expand Up @@ -955,6 +959,24 @@ public void setIgnoreCertificateErrors(boolean ignoreCertificateErrors) {
}
}

/**
* Returns the configured custom 'User-Agent' header value
*
* @return User-Agent header value
*/
public String getUserAgentHeader() {
return userAgentHeader;
}

/**
* Configures a custom value for the 'User-Agent' header
*
* @param userAgentHeader User-Agent header value
*/
public void setUserAgentHeader(String userAgentHeader) {
this.userAgentHeader = userAgentHeader;
}

/**
* Sets up Jersey client to ignore certificate errors.
*
Expand Down
Loading