Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(976)

Unified Diff: components/cronet/android/test/src/org/chromium/net/QuicTestServer.java

Issue 1777083002: Make QuicSimpleServerStream supports multipart response body (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quicsmaller
Patch Set: Rebased Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/cronet/android/test/quic_test_server.cc ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/test/src/org/chromium/net/QuicTestServer.java
diff --git a/components/cronet/android/test/src/org/chromium/net/QuicTestServer.java b/components/cronet/android/test/src/org/chromium/net/QuicTestServer.java
index 1344cc4d5c8114ae573571c4cdcc8ed0a5223f22..2f0648e48486f88b4992a893a8d7611fba80fb52 100644
--- a/components/cronet/android/test/src/org/chromium/net/QuicTestServer.java
+++ b/components/cronet/android/test/src/org/chromium/net/QuicTestServer.java
@@ -11,6 +11,9 @@ import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Wrapper class to start a Quic test server.
*/
@@ -23,8 +26,51 @@ public final class QuicTestServer {
private static final String KEY_USED = "quic_test.example.com.key";
private static final String[] CERTS_USED = {CERT_USED};
+ private static final List<Response> sResponses = new ArrayList<Response>();
+
+ /**
+ * Represents a response returned by the server.
+ */
+ public static class Response {
+ private final String mPath;
+ private final String[] mBodyChunks;
+ private final String[] mTrailers;
+
+ /**
+ * Constructs a Response.
+ * @param path path of the request url
+ * @param bodyChunks multipart response body
+ * @param trailers an array of response headers with keys at the even indices
+ * followed by the corresponding values at the odd indices.
+ */
+ public Response(String path, String[] bodyChunks, String[] trailers) {
+ mPath = path;
+ mBodyChunks = bodyChunks.clone();
+ mTrailers = trailers.clone();
+ }
+
+ public final String getPath() {
+ return mPath;
+ }
+
+ public final String[] getBodyChunks() {
+ return mBodyChunks.clone();
+ }
+
+ public final String[] getTrailers() {
+ return mTrailers.clone();
+ }
+ }
+
+ public static void addResponse(Response response) {
+ sResponses.add(response);
+ }
+
public static void startQuicTestServer(Context context) {
TestFilesInstaller.installIfNeeded(context);
+ for (Response r : sResponses) {
+ nativeAddResponse(r.getPath(), r.getBodyChunks(), r.getTrailers());
+ }
nativeStartQuicTestServer(TestFilesInstaller.getInstalledPath(context));
sBlock.block();
}
@@ -64,6 +110,8 @@ public final class QuicTestServer {
sBlock.open();
}
+ private static native void nativeAddResponse(
+ String path, String[] bodyChunks, String[] trailers);
private static native void nativeStartQuicTestServer(String filePath);
private static native void nativeShutdownQuicTestServer();
private static native String nativeGetServerHost();
« no previous file with comments | « components/cronet/android/test/quic_test_server.cc ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698