@@ -12,25 +12,27 @@ class ApiKeyRequestInterceptor implements RequestInterceptor {
1212 private static final String API_KEY_PARAM = "api-key" ;
1313 private static final String ACCEPT_HEADER = "Accept" ;
1414 private static final String JSON_CONTENT = "application/json" ;
15- private static final String API_CLIENT_HEADER = "x-client " ;
16- private static String API_CLIENT_VALUE ;
15+ private static final String API_CLIENT_HEADER = "User-Agent " ;
16+ private static final String API_CLIENT_VALUE ;
1717 static {
18+ String version ;
1819 try {
19- String version = CharStreams .toString (new InputStreamReader (ApiKeyRequestInterceptor .class
20- .getResourceAsStream ("/VERSION" )));
21- API_CLIENT_VALUE = String .format ("io.ipdata.client.java.%s" , version );
20+ version = CharStreams .toString (new InputStreamReader (ApiKeyRequestInterceptor .class
21+ .getResourceAsStream ("/VERSION" ))). replaceAll ( " \\ n" , "" ) ;
22+ version = String .format ("io.ipdata.client.java.%s" , version );
2223 }catch (Exception e ){
2324 e .printStackTrace ();
24- API_CLIENT_VALUE = "io.ipdata.client.java.UNKNOWN" ;
25+ version = "io.ipdata.client.java.UNKNOWN" ;
2526 }
27+ API_CLIENT_VALUE = version ;
2628 }
2729 private final String key ;
2830
2931 @ Override
3032 public void apply (RequestTemplate template ) {
3133 template .query (API_KEY_PARAM , key );
3234 template .header (ACCEPT_HEADER , JSON_CONTENT );
33- // template.header(API_CLIENT_HEADER, API_CLIENT_VALUE); TODO: the api doesn't seem to accept any header
35+ template .header (API_CLIENT_HEADER , API_CLIENT_VALUE );
3436 }
3537
3638}
0 commit comments