Giter VIP home page Giter VIP logo

Comments (10)

xanscale avatar xanscale commented on June 10, 2024 1

square/okhttp#7005 is about request body not response body.
https://github.com/square/retrofit/blob/master/retrofit/src/main/java/retrofit2/Response.java#L151 response body are always nullable

i will made some tests

from retrofit-adapters.

skydoves avatar skydoves commented on June 10, 2024 1

@xanscale Thanks for your contribution. It will be contained in the next release!

from retrofit-adapters.

skydoves avatar skydoves commented on June 10, 2024

Hey @xanscale, I'm a little bit confused about the terminology. Do you mean the empty body (Code 200 responses, right?)

from retrofit-adapters.

skydoves avatar skydoves commented on June 10, 2024

Additionally, what are the benefits of using a nullable body over the Unit type for the empty body?

from retrofit-adapters.

xanscale avatar xanscale commented on June 10, 2024

i have a service that can return body or not, in detail

  • 200 with body
  • 204 without body

Unit are used when you know that there is no body (or you dont care on it)

with my PR it works with both Foo? and Unit.

  • Unit can be used in caso of there isn't body or don't care about body
  • Foo? can be used in case of optional body

from retrofit-adapters.

skydoves avatar skydoves commented on June 10, 2024

@xanscale Btw is there a meaningful difference between an empty body and a nobody?

from retrofit-adapters.

xanscale avatar xanscale commented on June 10, 2024

@skydoves response body are OPTIONAL! same call can be with response body or not based on USER status.

from retrofit-adapters.

skydoves avatar skydoves commented on June 10, 2024

@xanscale I'm unsure if #18 works well because fundamentally OkHttp doesn't support NULL body yet: square/okhttp#7005.

And can we build any unit test cases for the nullable body similar to this? https://github.com/skydoves/retrofit-adapters/blob/main/retrofit-adapters-result/src/test/kotlin/com/skydoves/retrofit/adapters/result/ResultCallTest.kt#L87

from retrofit-adapters.

skydoves avatar skydoves commented on June 10, 2024

I got it. Thanks for the details!

from retrofit-adapters.

xanscale avatar xanscale commented on June 10, 2024

pushed unit test

from retrofit-adapters.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.