scoop:scoop.http.client:0.1.0
src/redirect/fields.scoop
Selected production source · src/redirect/fields.scoop
1
package scoop.http.client3
import scoop.http.HttpField4
import scoop.http.hasName6
internal fun redirectedClientFields(7
request: HttpRequest,8
droppingBody: Boolean,9
crossOrigin: Boolean10
): Array<HttpField> {11
val fields = ArrayList<HttpField>()12
for (field in request.suppliedFields) {13
if (14
crossOrigin &&15
(16
field.hasName("Authorization".toByteArray()) ||17
field.hasName("Cookie".toByteArray())18
)19
)20
continue21
if (droppingBody && redirectBodyField(field))22
continue23
fields.add(field)24
}25
return fields.toArray()26
}28
private fun redirectBodyField(field: HttpField): Boolean {29
for (30
name in [31
"Content-Length",32
"Content-Type",33
"Content-Encoding",34
"Content-Language",35
"Content-Location",36
"Content-Range",37
"Content-Disposition",38
"Content-MD5",39
"Digest",40
"Content-Digest",41
"Repr-Digest",42
"Trailer",43
"Expect"44
]45
) {46
if (field.hasName(name.toByteArray()))47
return true48
}49
return false50
}52
internal fun redirectedClientOptions(options: HttpCallOptions): HttpCallOptions =53
httpCallOptions {54
this.duplex = false55
this.expectContinue = false56
this.continueWait = options.continueWait57
this.decoding = options.decoding58
this.timeouts = options.timeouts59
this.onInformational = options.onInformational60
this.redirects = options.redirects61
this.retries = options.retries62
this.authentication = options.authentication63
this.proxy = options.proxy64
this.useCookies = options.useCookies65
this.cookieContext = options.cookieContext66
this.cacheMode = options.cacheMode67
this.observer = options.observer68
}