Forum Xamarin.iOS

Xamarin iOS and NULL response header Etag values

mikeacostamikeacosta USUniversity ✭✭✭

Etag header values (a hash in this case) from API requests are NULL after upgrading to Xamarin.iOS They are present in Xamarin.iOS 12.4.x.x, Android, any HTTP client tool, Swagger (basically the response from any other requests).

All other header values appear intact. Anyone having a similar issue. I'm trying to narrow it down, and am stuck on 12.4.x.x for now.

fyi - 12.8 appears to be the default for VS 2019 for Mac, which has it's own issue with Android, so we're sticking w/VS2017 for now, as well.


  • LandLuLandLu Member, Xamarin Team Xamurai

    Are you developing projects on Visual Studio 2017 for Windows and try to pair it to your Mac?
    If so, you have to keep them using the same version of Xamarin.iOS. As Visual Studio 2017 still consumes the Xamarin.iOS now, this error occurs. You could move to Visual Studio 2019 from 2017. It has a new appearance and matches the Xamarin.iOS version as VS for Mac, I guess you would like it.

  • mikeacostamikeacosta USUniversity ✭✭✭

    Yup, I understand that. I've paired to my Mac and ran solutions w/both versions. The issue is 12.8 appears to break response header values on iOS. A colleague and I both experience this.

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai

    ETag is a response header, and primiarily designed for caching, do you mean the response header that you captured is null when testing with Xamarin.iOS 12.8?

    If so, could you tell me which server you are using? And please post the codes for your http request, you can remove any sensitive information.

  • mikeacostamikeacosta USUniversity ✭✭✭

    Thanks for the reply. ETag is this case is a hash assigned from a metadata response from the AWS S3 API when hitting the corresponding S3 endpoint. The HTTP calls from Xamarin are wrapped in a custom .NET Standard library that uses basic System.Net.Http methods, nothing fancy. As mentioned, it all works as expected with everything except after moving to iOS 12.8.

    The following line in the SERVER-SIDE code gets an AWS-specific response with ContentLength, LastModified and ETag properties, each with values as expected.

    var response = await _amazonS3.GetObjectMetadataAsync(request);
 the Etag hash is getting "lost" somewhere when making the mobile-side request using IOS 12.8. Android is fine, as are Postman, and iOS 12.4.

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai

    Thanks for all the details. So, I can't test it using AWS S3 as I don't have any AWS account. Therefore I created a local Node.js Server with ETag Enabled:


    Visual Studio on WIndows\Visual Studio for Mac (Both Tried)
    Simulator:iphone XR iOS 12.2

    server codes:

    const express = require('express')
    const app = express()
    const port = 3000
    app.set('etag', 'strong');
    app.get('/', (req, res) => res.send('Hello World!'));
    app.listen(port, () => console.log(`Example app listening on port ${port}!`))

    and call the url in both Xamarin.iOS and Xamarin.Forms blank projects using below codes:

    HttpClient client = new HttpClient();
    var uri = new Uri(string.Format("internal ip address:3000", string.Empty));
    var response=await client.GetAsync(uri);
    if (response.IsSuccessStatusCode)
         var headers = response.Headers;

    And it works fine, I can get the Etag correctly.

    Here are a few things you can try:
    1. Retry it using blank projects.
    2. Try it with other url call. As far as I know, uses Etag in headers, you can try wiki's url.

    If the problem persists, could you maybe share a basic demo that can repro this issue?


  • mikeacostamikeacosta USUniversity ✭✭✭
    edited May 2019

    @ElvisXia Thanks again for the info. Here's a sample S3 link with Etag header value:

    It would be great if you could test 12.8 with that (I don't want to upgrade my environment). Also, here's some info about S3 etags:

    Lastly, AWS offers a "free tier" to new accounts for a year. Anyone can play with free tier-eligible configurations on various services, including S3, during this period.

  • mikeacostamikeacosta USUniversity ✭✭✭

    Hi @ElvisXia just wondering if there is (or will be) any update on this? My team is holding off on upgrading to 12.8. Thanks.

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai

    @mikeacosta Sorry, due to credit issue. I'm not able to test amazon S3 service. I've already tried bound my account to my only credit card. But the validation never succeed.

  • mikeacostamikeacosta USUniversity ✭✭✭

    @ElvisXia Thanks for the reply. I'll try to wrap the request in a .NET Standard library. Would that help?

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai
    edited May 2019

    @mikeacosta That definitly worth a try. You are also welcomed to raise an issue on Xamarin.iOS Github Repo if the issue persists.

  • mikeacostamikeacosta USUniversity ✭✭✭

    So, anyone else having response header issues with 12.8?

    In addition to the aforementioned issue, I also get duplicate Content-Length headers. Rolling back to 12.4 fixes this. And again, no other API consumers/clients have this issue.

Sign In or Register to comment.