Skip to content

Instantly share code, notes, and snippets.

@swankjesse
Created February 21, 2016 16:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swankjesse/981fcae102f513eb13ed to your computer and use it in GitHub Desktop.
Save swankjesse/981fcae102f513eb13ed to your computer and use it in GitHub Desktop.
Sample bug report for OkHttp
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class OkHttpBug {
@Rule public final MockWebServer server = new MockWebServer();
@Test public void test() throws Exception {
server.enqueue(new MockResponse()
.addHeader("Content-Type: text/plain")
.setBody("abc"));
Request request = new Request.Builder()
.url(server.url("/path"))
.header("User-Agent", "Test Case")
.build();
OkHttpClient client = new OkHttpClient();
Call call = client.newCall(request);
Response response = call.execute();
assertEquals("text/plain", response.header("Content-Type"));
assertEquals("abc", response.body().string());
RecordedRequest recordedRequest = server.takeRequest();
assertEquals("/path", recordedRequest.getPath());
assertEquals("Test Case", recordedRequest.getHeader("User-Agent"));
}
}
@niushicha1
Copy link

java.io.EOFException: \n not found: size=0 content=… #2849

@nightairjj
Copy link

This is imagration i don't no how to test but trying to get all operating systems to sync

@nightairjj
Copy link

@nightairjj
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment