mirror of
https://github.com/corda/corda.git
synced 2025-01-18 10:46:38 +00:00
throwing clearer error message when not supported 301 response code is used (#6296)
This commit is contained in:
parent
9f2bd1dcae
commit
14b9bc2c53
@ -33,6 +33,7 @@ import java.lang.reflect.Member
|
||||
import java.lang.reflect.Modifier
|
||||
import java.math.BigDecimal
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.HttpURLConnection.HTTP_MOVED_PERM
|
||||
import java.net.HttpURLConnection.HTTP_OK
|
||||
import java.net.Proxy
|
||||
import java.net.URI
|
||||
@ -478,9 +479,13 @@ fun URL.post(serializedData: OpaqueBytes, vararg properties: Pair<String, String
|
||||
@DeleteForDJVM
|
||||
fun HttpURLConnection.checkOkResponse() {
|
||||
if (responseCode != HTTP_OK) {
|
||||
if(responseCode == HTTP_MOVED_PERM) {
|
||||
throw IOException("Response Code $responseCode Moved Permanently cannot be used here. We only accept $HTTP_OK responses.")
|
||||
} else {
|
||||
throw IOException("Response Code $responseCode: $errorMessage")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteForDJVM
|
||||
val HttpURLConnection.errorMessage: String? get() = errorStream?.let { it.use { it.reader().readText() } }
|
||||
|
Loading…
Reference in New Issue
Block a user