set user agent
This commit is contained in:
parent
e66af3ab74
commit
fb442a16fd
2 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
group = org.xbib
|
||||
name = oai
|
||||
version = 2.5.0
|
||||
version = 2.5.1
|
||||
|
||||
gradle.wrapper.version = 6.6.1
|
||||
xbib-content.version = 2.6.2
|
||||
|
|
|
@ -39,6 +39,8 @@ public class OAIClient {
|
|||
|
||||
private final HttpClient httpClient;
|
||||
|
||||
private String userAgent;
|
||||
|
||||
public OAIClient(String baseURL) {
|
||||
this.baseURL = baseURL;
|
||||
this.httpClient = HttpClient.newBuilder()
|
||||
|
@ -46,6 +48,10 @@ public class OAIClient {
|
|||
.build();
|
||||
}
|
||||
|
||||
void setUserAgent(String userAgent) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* This verb is used to retrieve information about a repository.
|
||||
* Some of the information returned is required as part of the OAI-PMH.
|
||||
|
@ -61,6 +67,7 @@ public class OAIClient {
|
|||
HttpRequest httpRequest = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url.build().toExternalForm()))
|
||||
.header("accept", "utf-8")
|
||||
.header("user-agent", userAgent != null ? userAgent : "xbib OAI client")
|
||||
.GET()
|
||||
.build();
|
||||
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
||||
|
|
Loading…
Reference in a new issue