HttpResponseMessage.Content.Headers ContentDisposition is null

后端 未结 2 1063
刺人心
刺人心 2021-01-07 18:49

When downloading a file with HttpClient, I\'m downloading first the headers and then the content. When headers are downloaded, I can see Headers collection on the Content pr

2条回答
  •  执笔经年
    2021-01-07 19:12

    The problem is with the trailing ; in the content-disposition header

            [Fact]
            public void ParseContentDispositionHeader()
            {
                var value = ContentDispositionHeaderValue.Parse("attachment; filename=GeoIP2-City_20140107.tar.gz");
                Assert.Equal("GeoIP2-City_20140107.tar.gz",value.FileName);
            }
    

    If I add the semi-colon the parsing will fail. If you look at the RFC6266 grammar, the semi-colon is only supposed to precede the parameter.

提交回复
热议问题