Merge "Supports to add a response for the given headers" am: c3b5c91eab am: 4c2c593a41
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1724310
Change-Id: Id601e94966f0e1a8e54082901d0829f090df945b
diff --git a/staticlibs/testutils/devicetests/com/android/testutils/TestHttpServer.kt b/staticlibs/testutils/devicetests/com/android/testutils/TestHttpServer.kt
index 7aae8e3..39ce487 100644
--- a/staticlibs/testutils/devicetests/com/android/testutils/TestHttpServer.kt
+++ b/staticlibs/testutils/devicetests/com/android/testutils/TestHttpServer.kt
@@ -54,12 +54,12 @@
fun addResponse(
uri: Uri,
statusCode: Response.IStatus,
- locationHeader: String? = null,
+ headers: Map<String, String>? = null,
content: String = ""
) {
addResponse(Request(uri.path
?: "", Method.GET, uri.query ?: ""),
- statusCode, locationHeader, content)
+ statusCode, headers, content)
}
/**
@@ -68,11 +68,13 @@
fun addResponse(
request: Request,
statusCode: Response.IStatus,
- locationHeader: String? = null,
+ headers: Map<String, String>? = null,
content: String = ""
) {
val response = newFixedLengthResponse(statusCode, "text/plain", content)
- locationHeader?.let { response.addHeader("Location", it) }
+ headers?.forEach {
+ (key, value) -> response.addHeader(key, value)
+ }
responses[request] = response
}