Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OkHttp with existing HttpUrlConnection code?

I've just started working on an (existing) Android project that uses HttpUrlConnection to communicate with a RESTful web service. Today I realized that one of the REST calls I need to make uses the PATCH method which HttpUrlConnection apparently doesn't support. While I was searching for a workaround, I ran across the OkHttp client which apparently does support the PATCH method. On the website for OkHttp it says:

"You can try out OkHttp without rewriting your network code. The okhttp-urlconnection module implements the familiar java.net.HttpURLConnection API.."

I downloaded the jar file (as well as the Okio dependency) and added them to my project. Unfortunately, I can't seem to find any information on their website (I looked through the wiki and javadocs) about how I can "try out OkHttp without rewriting" all my existing HttpUrlConnection code. Am I just misunderstanding what they mean by that statement or am I missing something obvious?

like image 801
bmt22033 Avatar asked Jul 13 '26 15:07

bmt22033


1 Answers

Take a look at OkUrlFactory, which comes in the okhttp-urlconnection module.

like image 159
Jesse Wilson Avatar answered Jul 15 '26 03:07

Jesse Wilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!