I need to get the content type from a specific URL. I know that we can do it by simply coding:
URL url = new URL("https://someurl.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("HEAD"); // Request Method: GET/POST/UPDATE...
connection.connect();
String contentType = connection.getContentType();
Since this blocks the UI thread (a synchronous operation), how to make a HTTP request using RxJava 2 on Android?
Notes:
- I don't want to make this using the AsyncTask. Why?
- This is related to RxJava 2 and not version 1.
- Give me a clear, simple and concise example if you can.