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

HttpHeaders: need case insensitive get, set, and put #104

Closed
wonderfly opened this issue Jan 9, 2015 · 4 comments
Closed

HttpHeaders: need case insensitive get, set, and put #104

wonderfly opened this issue Jan 9, 2015 · 4 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@wonderfly
Copy link
Contributor

From yan...@google.com on May 05, 2012 11:07:17

External references, such as a standards document, or specification? http://javadoc.google-http-java-client.googlecode.com/hg/1.8.3-beta/com/google/api/client/http/HttpHeaders.html Java environments (e.g. Java 6, Android 2.3, App Engine, or All)? All Please describe the feature requested. Unlike JSON and URL parameters, HTTP headers are case insensitive. However, the get, put, and set methods from GenericData are case sensitive. For example, here is an issue reported from a user:

httpRequest.getHeaders().setAccept("/");
httpRequest.getHeaders().set("accept", "text/plain");
httpRequest.execute();

java.lang.IllegalArgumentException: multiple headers of the same name (headers are case insensitive): accept
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:750)

There are three ways I can think of that we could potentially deal with that:

  1. Override get, set, and put in HttpHeaders to be case insensitive, OR
  2. Add getCaseInsensitive, setCaseInsensitive, and putCaseInsensitive to GenericData to provide this functionality, OR
  3. Force all HTTP headers to be lower case, and always toLowerCase() the HTTP header name in get, set, and put, perhaps adding a caseInsensitive parameter to GenericData to alter how it works internally for this case

Note that a case insensitive implementation for options 1 and 2 is generally slower than a case sensitive implementation because we have to iterate over all headers.

Original issue: http://code.google.com/p/google-http-java-client/issues/detail?id=104

@wonderfly wonderfly added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. imported priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 9, 2015
@wonderfly wonderfly self-assigned this Jan 9, 2015
@wonderfly
Copy link
Contributor Author

From mlin...@google.com on May 08, 2012 06:38:30

Owner: mlin...@google.com
Cc: -mlin...@google.com rmis...@google.com

@wonderfly
Copy link
Contributor Author

From yan...@google.com on May 23, 2012 12:42:33

I implemented option 3: http://codereview.appspot.com/6235044

Status: Started
Owner: yan...@google.com
Cc: mlin...@google.com

@wonderfly
Copy link
Contributor Author

From yan...@google.com on May 24, 2012 10:17:44

Status: Fixed

@jbower1950
Copy link

v1.2.3-alpha (latest for google-api-client-util on maven central - https://mvnrepository.com/artifact/com.google.api.client/google-api-client-util) includes com.google.api.client.util.GenericData which does not contain FLAGS nor carry out the need for FLAGS from your 9-Jan-2015 posting.

This results in the following when import com.google.api.client.http.HttpHeaders; (extended GenericData) is used during Google http login process:

java.lang.NoSuchMethodError: com.google.api.client.util.GenericData.(Ljava/util/EnumSet;)V
at com.google.api.client.http.HttpHeaders.(HttpHeaders.java:61)

All builds are labeled "alpha". Can someone make an effort to bring them in line with the rest of the api?

clundin25 pushed a commit to clundin25/google-http-java-client that referenced this issue Aug 11, 2022
…oken

Retry HTTP failures in ServiceAccountCredentials.refreshAccessToken
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants