-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom User-Agent for MapFishPrint.
This fixes #1955
- Loading branch information
Björn Höfling
committed
Aug 19, 2021
1 parent
2f70aeb
commit ebaf680
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
core/src/main/java/org/mapfish/print/http/UserAgentCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.mapfish.print.http; | ||
|
||
import org.apache.http.util.VersionInfo; | ||
|
||
/** | ||
* Utility class for the creation of the User-Agent string. | ||
* | ||
* @author bhoefling | ||
* | ||
*/ | ||
public final class UserAgentCreator { | ||
|
||
private static final String AGENT_NAME = "MapFishPrint"; | ||
|
||
/** | ||
* Private constructor. | ||
*/ | ||
private UserAgentCreator() { | ||
|
||
} | ||
/** | ||
* Builds a User-Agent string. | ||
* | ||
* @return User-Agent | ||
*/ | ||
public static String getUserAgent() { | ||
|
||
final String httpClientUserAgent = VersionInfo.getUserAgent("Apache-HttpClient", | ||
"org.apache.http.client", UserAgentCreator.class); | ||
|
||
// This is based on the code from HttpClient: | ||
final VersionInfo mapFishPrintVersionInfo = VersionInfo.loadVersionInfo("org.mapfish.print", | ||
UserAgentCreator.class.getClassLoader()); | ||
final String mfpRelease = mapFishPrintVersionInfo.getRelease(); | ||
|
||
final String userAgent = String.format("%s/%s %s", AGENT_NAME, mfpRelease, httpClientUserAgent); | ||
return userAgent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
info.release=@application.version@ | ||
info.module=MapFishPrint | ||
#info.timestamp=... |