Networking in browser
-
This is part of HttpClient impl:
suspend fun request( method: Http.Method, url: String, headers: Http.Headers = Http.Headers(), content: AsyncStream? = null, config: RequestConfig = RequestConfig() ): Response { //println("HttpClient.request: $method:$url") val contentLength = content?.getLength() ?: 0L var actualHeaders = headers if (content != null && !headers.any { it.first.equals(Http.Headers.ContentLength, ignoreCase = true) }) { actualHeaders = actualHeaders.withReplaceHeaders(Http.Headers.ContentLength to "$contentLength") } if (config.simulateBrowser) { actualHeaders = combineHeadersForHost(actualHeaders, null) } val response = requestInternal(method, url, actualHeaders, content).apply { if (config.throwErrors) checkErrors() }
For some reason it forces content-length header which throws error non-stops:
How to continue? It's impossible to override the current impl because of requestInternal() which isn't available outside this scope