snowplow / snowplow-java-tracker

Snowplow event tracker for Java. Add analytics to your Java desktop and server apps, servlets and games. (See also: snowplow-android-tracker)
http://snowplowanalytics.com
Apache License 2.0
24 stars 36 forks source link

Remove `org.apache.http.HttpHeaders` dependency in `OkHttpClientAdapter` #266

Closed paulboocock closed 2 years ago

paulboocock commented 3 years ago

Describe the bug We still import in org.apache.http.HttpHeaders within OkHttpClientAdapter, however OkHttp no longer imports HttpClient like it used to (a long time ago!).

https://github.com/snowplow/snowplow-java-tracker/blob/d60f3f75b9efbbca7310876f7e9f17d394d4540a/src/main/java/com/snowplowanalytics/snowplow/tracker/http/OkHttpClientAdapter.java#L29-L29

We don't actually need to use this import, we can just use the string values for the HttpHeader values.

https://github.com/snowplow/snowplow-java-tracker/blob/d60f3f75b9efbbca7310876f7e9f17d394d4540a/src/main/java/com/snowplowanalytics/snowplow/tracker/http/OkHttpClientAdapter.java#L134-L134

mscwilson commented 2 years ago

The .addHeader call on line 135 was .addHeader("Content-Type", Constants.POST_CONTENT_TYPE) originally, up until this bug fix #195. I'm not sure why that particular change - "Content-Type" to HttpHeaders.CONTENT_TYPE was made.

Edit: technically the first version was .addHeader("Content-Type", "application/json; charset=utf-8")

paulboocock commented 2 years ago

The .addHeader call on line 135 was .addHeader("Content-Type", Constants.POST_CONTENT_TYPE) originally, up until this bug fix #195. I'm not sure why that particular change - "Content-Type" to HttpHeaders.CONTENT_TYPE was made.

Edit: technically the first version was .addHeader("Content-Type", "application/json; charset=utf-8")

I'm not sure why I did it either. I think I likely just copy and pasted and my IDE auto imported it. Either way, going back to the string is the correct call.