fuel icon indicating copy to clipboard operation
fuel copied to clipboard

[3.x] Feedback

Open iNoles opened this issue 4 years ago • 13 comments

I am asking for any kind of feedback on the next version of Fuel that is based on OkHttp with a support of ktor. It is not backward compatibility. It requires Java 8+. If you want to use it on Android, it have to be Android 5+.

So far, there is one known issue on ktor is unsupported websockets.

iNoles avatar Jul 03 '20 05:07 iNoles

If you really want to test it,

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    implementation 'com.github.kittinunf.fuel:fuel:3.x-SNAPSHOT'
}

iNoles avatar Jul 09 '20 03:07 iNoles

I would like to test this with our KTOR application. Easier said than done because everything has changed and the changes are really major and only very thing documentation exists.

Due to this being such a major refactoring I at least would like to see some kind of migration guide. Or just a little bit more documentation how does the new API work.

I have so many questions by just trying to set up the environment to our old project.

fuel-coroutine package is gone? Is it now in the core? fuel-jackson package is gone? is it now in the core? or part of OKHTTP?

How to replace FuelManager?

How to handle async request with the new API?

How to create an instance from Fuel with custom OKHttp configuration?

Here's few things that popped in to my mind by just trying replace the 2.x with 3.x.

niom avatar Sep 03 '20 13:09 niom

It is really coroutine-based HTTP Client with fully async. I can add jackson back.

val client = OkHttpClient.Builder()
        .addNetworkInterceptor {
            val originalResponse = it.proceed(it.request())
            originalResponse.newBuilder()
                .body(ProgressResponseBody(originalResponse.body!!, progressListener))
                .build()
        }.build()
    val httpLoader = HttpLoader.Builder().okHttpClient(client).build()

If you want to add custom OkHttp configuration for it

on Android, you can use the HttpLoaderFactory on the Application class to simplified the singleton.

iNoles avatar Sep 03 '20 23:09 iNoles

Jackson is now added to the 3.x branch.

iNoles avatar Sep 07 '20 19:09 iNoles

Let's move our development effort to 3.x!

kittinunf avatar Oct 26 '20 12:10 kittinunf

How long until 3.x is released? I could hardly wait~~~

wosika avatar Jan 11 '22 14:01 wosika

I tried the latest snapshot because it doesn't suffer from #827. Here's some feedback:

It works fine, but seems surprisingly bare-bones compared to the previous version. I'm missing things like:

  • a nice way to handle url parameters
  • adding headers one by one
  • jackson extension for body
  • a fluent way to build and send a complex request

F43nd1r avatar Feb 24 '23 11:02 F43nd1r

I tried the latest snapshot because it doesn't suffer from #827. Here's some feedback:

It works fine, but seems surprisingly bare-bones compared to the previous version. I'm missing things like:

  • a nice way to handle url parameters
  • adding headers one by one
  • jackson extension for body
  • a fluent way to build and send a complex request
  1. I may be thinking about it. You could write issues about it. sounds like Extensions per platform. like Java, HttpURL from OkHttp.

  2. Headers already Map.

  3. Sorry, I can't do this over multiplatform

  4. what kind of complex requests you are looking for?

iNoles avatar Feb 26 '23 05:02 iNoles

  1. What's the issue with how 2.x did it?
Fuel.get("http://base.url/path", "param1" to "value1", "param2" to "value2")

I like to write things like

fun Request.Builder.addSomeBasicHeaders() = apply {
    // add headers every request needs
}

request.addSomeBasicHeaders().addHeader("specificHeader", "value")

But the request builder in 3.0 doesn't allow for this pattern.


Something like

fun Request.Builder.objectBody(body: Any) = body(objectMapper.writeValueAsString(body))

should work

In 2.x you could write something like

Fuel.post(...)
    .header(...)
    .header(...)
    .body(...)
   .responseObject<...>()

This is the pattern I'm missing in 3.0

F43nd1r avatar Feb 26 '23 11:02 F43nd1r

With https://github.com/kittinunf/fuel/blob/main/fuel/src/commonMain/kotlin/fuel/Fuels.kt and https://github.com/kittinunf/fuel/blob/main/fuel/src/commonMain/kotlin/fuel/Strings.kt

you can do Fuel.post("url", "Hello there", mapOf("")).body

or

"url".httpPost("Hello There", mapOf("")).body

you replace response body (String) with another library like toJson()

iNoles avatar Feb 26 '23 16:02 iNoles

@F43nd1r

About parameters, Do you use other types other than String?

iNoles avatar Mar 08 '23 01:03 iNoles

I think it's convenient to be able to pass in booleans and numbers, but I guess not really necessary

F43nd1r avatar Mar 08 '23 12:03 F43nd1r

I think it's convenient to be able to pass in booleans and numbers, but I guess not really necessary

oh thanks, I already make a PR about it with parameters.

iNoles avatar Mar 08 '23 21:03 iNoles