request
Executes an HTTP request using the provided HttpRequestBuilder configuration.
This function sends a request with parameters specified in the builder, allowing customization of request settings such as URL, HTTP method, headers, and body.
Usage Example
val client = HttpClient()
val response = client.request {
url("https://ktor.io")
method = HttpMethod.Get
}
This example demonstrates making a GET request to "https://ktor.io".
Note
In addition to this generic HttpClient.request method, there are more specific extension functions, such as HttpClient.get, HttpClient.post, HttpClient.put, and HttpClient.delete, which are often more convenient for common HTTP methods.
Return
HttpResponse The response received from the server after executing the request.
For more details, see Making requests.
Parameters
The HttpRequestBuilder used to configure request parameters. Defaults to an empty builder if none is provided.
Executes an HTTP request using the provided HttpRequestBuilder configuration.
This function sends a request with parameters specified in the block, allowing customization of request settings such as URL, HTTP method, headers, and body.
Usage Example
val client = HttpClient()
val response = client.request {
url("https://ktor.io")
method = HttpMethod.Get
}
This example demonstrates making a GET request to "https://ktor.io".
Note
In addition to this generic HttpClient.request method, there are more specific extension functions, such as HttpClient.get, HttpClient.post, HttpClient.put, and HttpClient.delete, which are often more convenient for common HTTP methods.
Return
HttpResponse The response received from the server after executing the request.
For more details, see Making requests.
Parameters
The HttpRequestBuilder block used to configure request parameters. Defaults to an empty builder if none is provided.
Executes an HTTP request using the provided HttpRequestBuilder configuration.
This function sends a request to the urlString with parameters specified in the block, allowing customization of request settings such as URL, HTTP method, headers, and body.
Usage Example
val client = HttpClient()
val response = client.request("https://ktor.io") {
method = HttpMethod.Get
}
This example demonstrates making a GET request to "https://ktor.io".
Note
In addition to this generic HttpClient.request method, there are more specific extension functions, such as HttpClient.get, HttpClient.post, HttpClient.put, and HttpClient.delete, which are often more convenient for common HTTP methods.
Return
HttpResponse The response received from the server after executing the request.
For more details, see Making requests.
Parameters
The URL to which the request is sent.
The HttpRequestBuilder used to configure request parameters. Defaults to an empty builder if none is provided.
Executes an HTTP request using the provided HttpRequestBuilder configuration.
This function sends a request to url with parameters specified in the block, allowing customization of request settings such as URL, HTTP method, headers, and body.
Usage Example
val client = HttpClient()
val response = client.request("https://ktor.io") {
method = HttpMethod.Get
}
This example demonstrates making a GET request to "https://ktor.io".
Note
In addition to this generic HttpClient.request method, there are more specific extension functions, such as HttpClient.get, HttpClient.post, HttpClient.put, and HttpClient.delete, which are often more convenient for common HTTP methods.
Return
HttpResponse The response received from the server after executing the request.
For more details, see Making requests.
Parameters
The URL to which the request is sent.
The HttpRequestBuilder used to configure request parameters. Defaults to an empty builder if none is provided.
Creates an HttpRequestBuilder and configures it using block.