@@ -148,29 +148,25 @@ private static String urlEncodePair(String k, String v) throws UnsupportedEncodi
148
148
static Map <String , String > getHeaders (String apiKey ) {
149
149
Map <String , String > headers = new HashMap <String , String >();
150
150
headers .put ("Accept-Charset" , CHARSET );
151
- headers .put ("User-Agent" , String .format ("EasyPost/v2 JavaClient/%s" , EasyPost .VERSION ));
151
+ headers .put ("User-Agent" , String .format ("EasyPost/v2 JavaClient/%s Java/%s OS/%s OSVersion/%s OSArch/%s " +
152
+ "Implementation/%s" , EasyPost .VERSION , System .getProperty ("java.version" ),
153
+ convertSpaceToHyphen (System .getProperty ("os.name" )), System .getProperty ("os.version" ),
154
+ convertSpaceToHyphen (System .getProperty ("os.arch" )),
155
+ convertSpaceToHyphen (System .getProperties ().getProperty ("java.vm.name" ))));
152
156
153
157
if (apiKey == null ) {
154
158
apiKey = EasyPost .apiKey ;
155
159
}
156
160
157
161
headers .put ("Authorization" , String .format ("Bearer %s" , apiKey ));
158
162
159
- // debug headers
160
- String [] propertyNames = { "os.name" , "os.version" , "os.arch" ,
161
- "java.version" , "java.vendor" , "java.vm.version" ,
162
- "java.vm.vendor" };
163
- Map <String , String > propertyMap = new HashMap <String , String >();
164
- for (String propertyName : propertyNames ) {
165
- propertyMap .put (propertyName , System .getProperty (propertyName ));
166
- }
167
- propertyMap .put ("lang" , "Java" );
168
- propertyMap .put ("publisher" , "EasyPost" );
169
- headers .put ("X-Client-User-Agent" , gson .toJson (propertyMap ));
170
-
171
- return headers ;
163
+ return headers ;
172
164
}
173
165
166
+ private static String convertSpaceToHyphen (String string ) {
167
+ return string .replace (' ' , '-' );
168
+ }
169
+
174
170
private static javax .net .ssl .HttpsURLConnection createEasyPostConnection (String url , String apiKey ) throws IOException {
175
171
URL easypostURL = null ;
176
172
String customURLStreamHandlerClassName = System .getProperty (CUSTOM_URL_STREAM_HANDLER_PROPERTY_NAME , null );
0 commit comments