none
HttpClient - Header - ContentLocation RRS feed

  • Question

  • Hi,

    I used the nuget package "https://www.nuget.org/packages/Microsoft.Net.Http/" Microsoft.Net.HttpClient to manipulate a REST API from a portable class library that support :

    .Net Framework 4.5

    W8

    WP8.1

    Xamarin.Android

    Xamarin.IOS

    Xamarin.IOS (classic)

    This API need for a specific command a parameter "Content-Location" in the header.

    I use the header of the HttpRequestMessage.

    I can insert the key "ContentLocation" but not the key "Content-Location". In the RFC 2616 the header key is well "Content-Location".

    Is there a way to force a specific key in the header ?
    Is there a way to notify this bug to the specific team if it is one ?

    thanks

    Monday, June 15, 2015 9:23 AM

Answers

  • the "-" doesn't causes any problems in the RFC it's "Content-Location" , like "Content-Type".

    In the web environment the character "-" is one of the most tolerated.

    The tricks that i apply works well and i see no problems with fiddler.

    Wednesday, June 17, 2015 8:45 AM

All replies

  • Hello Thumerel mickael,

    >>I can insert the key "ContentLocation" but not the key "Content-Location". In the RFC 2616 the header key is well "Content-Location".

    If you mean that when you insert “ContentLocation”, your app would work fine while when you insert “Content-Location”, it does not work any more? Maybe you could share some code with us so that we could help make a test about it.

    >>Is there a way to notify this bug to the specific team if it is one ?

    Since this is a nugget package, if you have any question about the installed library, you could click “Contact Owner” on left side of the download page:https://www.nuget.org/packages/Microsoft.Net.Http/ContactOwners and send this scenario to them.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 16, 2015 2:26 AM
    Moderator
  • I found a solution, bad solution but a solution.

    It seems that the HttpRequestHeader have a black list of header key.

    That why the key "ContentLocation" work and the key "Content-Location" doesn't.

    It must have a reason but i don't found.

    So i get the HashSet by reflection and clean it.

    HttpRequestMessage msg;

    var type = msg.Headers.GetType();
    var fields = type.GetRuntimeFields().FirstOrDefault(f => f.Name == "invalidHeaders");
    HashSet<string> invalid = (HashSet<string>)fields.GetValue(msg);
    invalid.Clear();

    There is another way to allow some header key ?

    Tuesday, June 16, 2015 8:36 AM
  • Hello Thumerel mickael,

    >>It must have a reason but i don't found.

    In my opinion, the property is designed to “ContentLocation” rather than “Content-Location”, because the “-” would separate “ContentLocation” and would causes a compiled error.

    Please check if the send request is "Content-Location" format or "ContentLocation", you could caupte the request by tools as fiddler.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 17, 2015 6:43 AM
    Moderator
  • the "-" doesn't causes any problems in the RFC it's "Content-Location" , like "Content-Type".

    In the web environment the character "-" is one of the most tolerated.

    The tricks that i apply works well and i see no problems with fiddler.

    Wednesday, June 17, 2015 8:45 AM
  • Hello,

    I mean we cannot declare a variable as “xxx-xxx” in .Net code. Anyway, it is glad to see you get a workaround.

    Cheers.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 23, 2015 5:24 AM
    Moderator