java.io.IOException when using Retrofit with rxandroid
<p>I need to make HTTP DELETE request to my server with body provided.</p>

<p>I build the retrofit object in the following way:</p>

<pre><code>        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder()
                .addInterceptor(interceptor)
                .retryOnConnectionFailure(true)
                .connectTimeout(2, TimeUnit.MINUTES)
                .readTimeout(5, TimeUnit.MINUTES)
                .writeTimeout(5, TimeUnit.MINUTES)
                .build();

        Gson gson = new GsonBuilder()
                .registerTypeAdapter(Date.class, new GsonUTCDateAdapter())
                .registerTypeAdapter(LocalDate.class, new GsonLocalDateAdapter())
                .create();

        return new Retrofit.Builder()
                .baseUrl(AppConfig.API_BASE_URL)
                .client(client)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
</code></pre>

<p>My Retrofit service method is:</p>

<pre><code>@HTTP(method = "DELETE", path = "selfie/{publicId}/action/1", hasBody = true)
Observable&lt;SimpleResponseModel&gt; unlike(
    @Path("publicId") String publicId,
    @Body AuthorisedRequestModel model
);
</code></pre>

<p>I handle retrofit request/response in following way:</p>

<pre><code>                NetworkHelper
                .getRetrofit()
                .create(SelfieService.class)
                .unlike(selfieModel.getPublicId(), new AuthorisedRequestModel())
                .subscribeOn(Schedulers.io())

                .subscribe(new CustomSubscriber&lt;SimpleResponseModel&gt;() {
                    @Override
                    public void onNext(SimpleResponseModel simpleResponseModel) {
                        ErrorHelper.handleServerError(simpleResponseModel);
                    }
                });
</code></pre>

<p>I should mention, that all another requests <strong>GET</strong>,<strong>POST</strong> and <strong>PUT</strong> are working, but all <strong>DELETE</strong> requests are return me following error, from log:</p>

<pre><code>HTTP FAILED: java.io.IOException: unexpected end of stream on okhttp3.Address@c6ec992c
</code></pre>

<p>So the request don't reach the server.</p>

<p>When I used Retrofit without <em>rxandroid</em> and made queries in <em>AsyncTask</em>s everything worked well.</p>

<p>Caused by:</p>

<pre><code>Caused by: java.io.EOFException: \n not found: size=0 content=…
 at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:215)
 at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
</code></pre>