I am sending a get request with username and passw...
# ktor
c
I am sending a get request with username and password for basic authentication in the url, unfortunately the password contains $ sign, how do I disable the url encoding? I cannot send the a password with a $ as it turns into %24, pls help.
only the Apache client does it, so i change client!
but still no solution on this
h
You should never put the password in the url. Only in some browsers, this is converted to the correct header. Other clients, like curl using terminal don't convert it. Please use the correct header in the request builder:
Copy code
get("/") {
    header(HttpHeaders.Authorization, "Basic ${"$username:$password".encodeBase64()}")
}
👍 3
a
You can set the value of
urlEncodingOption
property to
<http://UrlEncodingOption.NO|UrlEncodingOption.NO>_ENCODING
to disable encoding. Here is an example:
Copy code
val url = URLBuilder().apply {
    parameters.urlEncodingOption = UrlEncodingOption.NO_ENCODING
    parameters.append("username", "john")
    parameters.append("password", "sec\$ret")
}

println(url.buildString())
👍 2