-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from nomiero/master
Add ability to create a custom user-agent suffix
- Loading branch information
Showing
8 changed files
with
79 additions
and
7 deletions.
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
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
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
34 changes: 34 additions & 0 deletions
34
src/com/microsoft/azure/documentdb/UserAgentContainer.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,34 @@ | ||
package com.microsoft.azure.documentdb; | ||
|
||
/** | ||
* The user agent object, which is used to track the version of the SDK. | ||
*/ | ||
class UserAgentContainer { | ||
|
||
private static final String BASE_USER_AGENT = HttpConstants.Versions.USER_AGENT; | ||
private static final int MAX_SUFFIX_LENGTH = 64; | ||
private String suffix; | ||
private String userAgent; | ||
|
||
UserAgentContainer() { | ||
this.suffix = ""; | ||
this.userAgent = BASE_USER_AGENT; | ||
} | ||
|
||
public void setSuffix(String suffix) { | ||
if(suffix.length() > MAX_SUFFIX_LENGTH) { | ||
suffix = suffix.substring(0, MAX_SUFFIX_LENGTH); | ||
} | ||
|
||
this.suffix = suffix; | ||
this.userAgent = BASE_USER_AGENT.concat(this.suffix); | ||
} | ||
|
||
public String getSuffix() { | ||
return this.suffix; | ||
} | ||
|
||
String getUserAgent() { | ||
return this.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