Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand documentation for custom requests to cover additional use cases #395

Open
fpiraneo opened this issue Feb 8, 2021 · 5 comments
Open

Comments

@fpiraneo
Copy link

fpiraneo commented Feb 8, 2021

Volley seems to be a nice library for a very basic usage but it seems missing (or not documented) some critical functionalities, like:

  1. How can I set customer headers on request?
  2. How can I read headers on response from the server?
  3. How can I send a plain text or binary payload when making a POST or PUT request?
  4. How can I read http status codes (200 = OK, 404 = not found, ... do you mean?)

All this in Kotlin, of course, the language google is pushing!

@jpd236
Copy link
Collaborator

jpd236 commented Feb 8, 2021

It seems to me that https://developer.android.com/training/volley/request-custom covers a lot of this, and includes Kotlin snippets, though perhaps not always explicitly.

  1. The example GsonRequest demonstrates passing in a Map<String, String> of request headers to the Request constructor which will be included in the request. The mechanism is by returning the headers from getHeaders().
  2. The documentation for parseNetworkResponse mentions that NetworkResponse includes the response headers.
  3. This doesn't seem to be mentioned explicitly, but you would override Request#getBody() to send a custom payload in the request. (And Request#getBodyContentType to set the Content-Type header).
  4. As with 2, NetworkResponse includes the status code.

Will leave this open to track better documentation regarding 3. If you have other concrete suggestions on how that page could have helped you more, let us know.

@fpiraneo
Copy link
Author

  1. I don't want to be compelled to use gson for deserialization; not always I need deserialization; so again: It's possibile to use volley with custom headers? Please provide practical example;
  2. Very confused, sorry, very confused;
  3. Complete doc MUST mentions explicitly how things works;
  4. Maybe a working example will clarify this point.

Again: a three theoretical example are very poor documentation for a product made by Google! I think you can do better with your 135,301 employees!

@paulsmithkc
Copy link
Contributor

There a large multitude of errors in the example Java code, which have been there for years. As far a I can tell there is no mechanism to recommend changes to Android Developers Training pages. If the documentation was stored in GitHub as markdown files we could create Pull Requests to suggest fixes/corrections.

@jpd236 jpd236 changed the title Nice lib but poorly documented Expand documentation for custom requests to cover additional use cases Mar 29, 2021
@jpd236
Copy link
Collaborator

jpd236 commented Mar 29, 2021

There a large multitude of errors in the example Java code, which have been there for years. As far a I can tell there is no mechanism to recommend changes to Android Developers Training pages. If the documentation was stored in GitHub as markdown files we could create Pull Requests to suggest fixes/corrections.

That's a fair point, although there would be drawbacks to migrating the existing doc given how long it has been around. I see this more as a limitation of the developer.android.com page that could be more broadly beneficial (ability to suggest edits to docs there).

In the mean time, please do feel free to file an issue on the GitHub tracker pointing out any specific issues you see with the example code / docs. I'm happy to push those through. This bug is more about omissions for certain custom cases rather than actual Code errors.

@paulsmithkc
Copy link
Contributor

There are enough updates to recommend, that submitting them as markdown files like the easiest way. #405 (comment)

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

No branches or pull requests

3 participants