Skip to content

Conversation

@jdalvar3z
Copy link

@jdalvar3z jdalvar3z commented Oct 22, 2025

Solve 204 No Content Error

See issue #431 for Context

  • Refactored parseNetworkResponse to handle 204 No Content responses gracefully.
  • Added check for null or empty response.data to return Response.success with an empty JSONObject instead of triggering a Response.error.
  • Optimized code by extracting HttpHeaderParser.parseCacheHeaders to a local variable for reuse, improving readability and performance.
  • Maintained existing functionality for non-empty responses while enhancing clarity and maintainability.

@google-cla
Copy link

google-cla bot commented Oct 22, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jpd236
Copy link
Collaborator

jpd236 commented Oct 22, 2025

My stance here is largely unchanged from what I said here: #431 (comment)

In particular, we're making an assumption that an empty response body should be treated as equivalent to "{}", and while that seems logical, I can easily imagine existing applications that would not expect that change and could fail in significant ways. While I agree this would probably have made sense if this were a brand new class, I'm very hesitant to change the existing behavior of a long-standing class in a semantically meaningful way.

Our priority at this point is maintaining Volley's functionality for existing users. New users shouldn't be using these classes as noted there - or, for that matter, Volley in general. There are more modern recommendations at https://developer.android.com/develop/connectivity/network-ops/connecting#choose-http-client. So while it may seem counterintuitive, I think it's best to maintain existing behavior in case of any doubt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants