Skip to content

Instantly share code, notes, and snippets.

@stigkj
Last active September 8, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stigkj/fce1239ae09a3327b88bf134c77ef1d1 to your computer and use it in GitHub Desktop.
Save stigkj/fce1239ae09a3327b88bf134c77ef1d1 to your computer and use it in GitHub Desktop.
HEAD request timing out
import okhttp3.*;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class OkHttpBug {
@Test
public void test() throws Exception {
Request request = new Request.Builder()
.head()
.url("http://www.sunhotels.net/SunHotels.net/HotelInfo/hotelImage.aspx?full=1&id=528422")
.build();
OkHttpClient client = new OkHttpClient();
Call call = client.newCall(request);
Response response = call.execute();
assertEquals(response.header("Content-Length"), "123");
assertNull(response.body());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment