PhotoBackup / client-android

The Android PhotoBackup client, made to free your pictures from your device
https://photobackup.github.io/
GNU General Public License v2.0
48 stars 15 forks source link

Adding UserAgent to http-client #25

Closed zealot128 closed 8 years ago

zealot128 commented 8 years ago

Right now, the http request does not use a UserAgent.

Maybe we can add a UserAgent header like "PhotoBackup Android VERSION" to the HTTP request? That would make it easier to distinguish the requests from stuff like bots/crawler or (in my case) manual uploads with the browser.

Async-http seems to have a Method on AsyncHttpClient:

https://github.com/loopj/android-async-http/blob/9c7b6d41e3b84a5d62dfc914c29536708fc7dcdb/library/src/main/java/com/loopj/android/http/AsyncHttpClient.java#L640

So somewhere in the PBMediaSender constructor a client.setUserAgent().

stephanepechard commented 8 years ago

Yes, that would be a nice addition. Hope to be able to do it soon (not so sure). I have also to evaluate the possibility to use okHttp instead, but the point is still valid anyway. Thanks

stephanepechard commented 8 years ago

Ok, it was a faster than I thought... I just committed a switch from loopj AsyncHttpClient to OkHttp client. It should (I trust you on this) fix #23 and I added a UserAgent for this one.

May you try this version (0.8.1-dev) and tell me if this is ok for you?

stephanepechard commented 8 years ago

Done in 4a9e39c12234e70d0d829c204a280d6a6f5dd62d