summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2021-06-22 22:53:26 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-06-22 22:53:26 +0000
commit05146ed64ac35002f58f3fcd53a66e13989d6f5a (patch)
tree85693285a5bd3002f6c184315fdeb77308ce2c17
parent719cb55e9590bdbe44a34094de47b802d80157c9 (diff)
parent64d39c73119acdf8340d8f1b65966275279e5f83 (diff)
downloadnet-05146ed64ac35002f58f3fcd53a66e13989d6f5a.tar.gz
Merge "Supports to add a response for the given headers" into sc-dev
-rw-r--r--common/testutils/devicetests/com/android/testutils/TestHttpServer.kt10
1 files changed, 6 insertions, 4 deletions
diff --git a/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt b/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt
index 7aae8e3b..39ce4872 100644
--- a/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt
+++ b/common/testutils/devicetests/com/android/testutils/TestHttpServer.kt
@@ -54,12 +54,12 @@ class TestHttpServer(host: String? = null) : NanoHTTPD(host, 0 /* auto-select th
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 @@ class TestHttpServer(host: String? = null) : NanoHTTPD(host, 0 /* auto-select th
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
}