Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

WWW.get_responseHeaders failing in 2017.2.0f2

Discussion in '2017.2 Beta' started by Michael_C, Oct 5, 2017.

  1. Michael_C

    Michael_C

    Joined:
    Aug 15, 2013
    Posts:
    4
    With my first server call of a session, the responseHeaders dictionary will be null which throws an exception:

    NullReferenceException: Object reference not set to an instance of an object

    Similar to this:
    https://issuetracker.unity3d.com/is...ct-is-null-if-there-is-no-internet-connection

    However, I was not seeing this issue with 2017.1.1p3. Also, by running through Charles Proxy I can see all of the responseHeaders and the rest of the data. If I catch and ignore this NullReferenceException, I can continue to get all of the data except for the missing response headers.

    Anyone else seeing this issue, or know of a workaround? The Android prefab load times finally seem to be fixed in 2017.2 and I need to be able to update to this version.

    Michael
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,506
    This bug will be fixed soon. responseHeaders are null when they are not yet available (i.e. not yet received or request has failed). For now you have to explicitly check for null.
     
  3. Michael_C

    Michael_C

    Joined:
    Aug 15, 2013
    Posts:
    4
    In our situation, the responseHeaders should be available (I can see them in Charles Proxy and the request did not fail). We also rely on the data in the headers, so we can't just null check and ignore the fact that they are not there.
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,506
    Is request completed and successful?
    I'm also aware of (seemingly) android specific issue about headers being unavailable when chunked transfer is used, but that hasn't been confirmed yet. Is any of this similar to your case?
     
  5. Michael_C

    Michael_C

    Joined:
    Aug 15, 2013
    Posts:
    4
    Yes, the request is completed and successful.

    If I catch the null exception and continue, I am able to see the contents of the response body, just not the headers.

    We are not explicitly setting the chunkedTransfer parameter.

    I am seeing this on Android, but I have not verified whether it happens on iOS yet or not. It does not happen through the editor.

    Using Charles Proxy I get the following stats about the response:
    Response 4.23 KB
    TLS Handshake -
    Header 168 bytes
    Cookies -
    Body 4.07 KB
    Uncompressed Body 10.49 KB
    Compression 61.2% (gzip)
     
  6. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,506
    Please report a bug.