Skip to content

BoxAPIResponse getHeaderField should be case insensitive #619

Closed

Description

@thiccar

Description of the Issue

LargeFileUpload.upload() calls are failing because they fail to parse the Retry-After header from the commit response. This is because the headers are stored and looked up in a case-sensitive way. But as per HTTP spec (https://tools.ietf.org/html/rfc2616#section-4.2) header names are case-insensitive. This causes problems since BoxFileUploadSession.commit calls response.getHeaderField("retry-after") but the response from the server may have the header name as "Retry-After".

This leads to an exception (see stack trace below).

Fix should be pretty simple, use a case-insensitive map or all keys should be converted to lowercase before insertion/lookup in the map.

Versions Used

Java SDK: 2.20.1
Java: 1.8.0_152

Steps to Reproduce

https://gist.github.com/klk-/3661ce3ed35343b0ed0ef0ca66419cbd

Error Message, Including Stack Trace

Exception in thread "main" com.box.sdk.BoxAPIException: Unable to commit the upload session
at com.box.sdk.LargeFileUpload.uploadHelper(LargeFileUpload.java:136)
at com.box.sdk.LargeFileUpload.upload(LargeFileUpload.java:112)
at Main$.$anonfun$main$1(Main.scala:21)
at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:156)
at Main$.main(Main.scala:14)
at Main.main(Main.scala)
Caused by: com.box.sdk.BoxAPIException: Commit response content type is not application/json. The response code : 202
at com.box.sdk.BoxFileUploadSession.commit(BoxFileUploadSession.java:372)
at com.box.sdk.LargeFileUpload.uploadHelper(LargeFileUpload.java:133)
... 5 more

Activity

  1. carycheng commented on Jun 26, 2018

    @carycheng

    Hey @klk-

    Thank you for pointing this out, we have a pr out for this fix now - #620

    This fix will most likely go out with our weekly SDK release on Thursday.

    Thanks!

  2. mattwiller commented on Jun 27, 2018

    @mattwiller

    Fixed by #620

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions