Skip to content

ImageRequest method type #985

Answered by colinrtwhite
jpappdesigns asked this question in Q&A
Discussion options

You must be logged in to vote

Not out of the box, though you can create an extension for this. Here's the code to do this (note: this only works in the 2.x alpha versions):

private const val KEY = "http_method_type"

fun ImageRequest.Builder.httpMethod(method: String) = setParameter(KEY, method)

// Add this interceptor to the OkHttpClient that's used by your ImageLoader instance.
// https://coil-kt.github.io/coil/recipes/#using-a-custom-okhttpclient
class HttpMethodTypeInterceptor : Interceptor {

    fun intercept(chain: Interceptor.Chain): Response {
        val httpMethodType = chain.request.tag(Parameters::class.java)?.value(KEY)
        return if (httpMethodType == null) {
            chain.proceed(chain.request…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@jpappdesigns
Comment options

@jpappdesigns
Comment options

@colinrtwhite
Comment options

Answer selected by jpappdesigns
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants