Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# FileStreamResult无法识别Asp.Net Core 2.2中的多个http范围_C#_Asp.net Core_Curl_.net Core_Http Range - Fatal编程技术网

C# FileStreamResult无法识别Asp.Net Core 2.2中的多个http范围

C# FileStreamResult无法识别Asp.Net Core 2.2中的多个http范围,c#,asp.net-core,curl,.net-core,http-range,C#,Asp.net Core,Curl,.net Core,Http Range,我有这么简单的目的: [HttpGet] public IActionResult GetFileDirect() { var path = ...; // path to the file return File(System.IO.File.OpenRead(path), "text/plain", true); } 当前文件的内容为: abcdefghijklmnopqrstuvwxyz 正如您在return语句中看到的,我将true传递给enableRangePro

我有这么简单的目的:

[HttpGet]
public IActionResult GetFileDirect()
{
     var path = ...; // path to the file
     return File(System.IO.File.OpenRead(path), "text/plain", true);
}
当前文件的内容为:

abcdefghijklmnopqrstuvwxyz

正如您在return语句中看到的,我将true传递给enableRangeProcessing。在单量程请求的情况下,其工作正常:

curl-H范围:字节=0-8http://localhost:65318/api/File -我

以下是答复:

HTTP/1.1 206 Partial Content
Content-Length: 9
Content-Type: text/plain
Content-Range: bytes 0-8/26
Accept-Ranges: bytes
Server: Kestrel
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcY2ViaXlcRGVza3RvcFxSYW5nZVdlYlxSYW5nZVdlYlxhcGlcRmlsZQ==?=
X-Powered-By: ASP.NET
Date: Sat, 02 Nov 2019 17:46:49 GMT

abcdefghi
HTTP/1.1 200 OK
Content-Length: 26
Content-Type: text/plain
Accept-Ranges: bytes
Server: Kestrel
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcY2ViaXlcRGVza3RvcFxSYW5nZVdlYlxSYW5nZVdlYlxhcGlcRmlsZQ==?=
X-Powered-By: ASP.NET
Date: Sat, 02 Nov 2019 17:49:37 GMT

abcdefghijklmnopqrstuvwxyz

但是,在多范围请求的情况下,它将不考虑任何范围,并且将返回具有文件完整内容的OK响应:

curl -H  Range:bytes=0-8,12-15 http://localhost:65318/api/File -i
以下是答复:

HTTP/1.1 206 Partial Content
Content-Length: 9
Content-Type: text/plain
Content-Range: bytes 0-8/26
Accept-Ranges: bytes
Server: Kestrel
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcY2ViaXlcRGVza3RvcFxSYW5nZVdlYlxSYW5nZVdlYlxhcGlcRmlsZQ==?=
X-Powered-By: ASP.NET
Date: Sat, 02 Nov 2019 17:46:49 GMT

abcdefghi
HTTP/1.1 200 OK
Content-Length: 26
Content-Type: text/plain
Accept-Ranges: bytes
Server: Kestrel
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcY2ViaXlcRGVza3RvcFxSYW5nZVdlYlxSYW5nZVdlYlxhcGlcRmlsZQ==?=
X-Powered-By: ASP.NET
Date: Sat, 02 Nov 2019 17:49:37 GMT

abcdefghijklmnopqrstuvwxyz

我深入到比@Nkosi更深一点的源代码中,以找到解析范围的位置,请看


我深入到比@Nkosi更深一点的源代码中,以找到解析范围的位置,请看


查看源代码及其处理范围标头的方式无法解析请求中的范围。查看源代码及其处理范围标头的方式无法解析请求中的范围。