简体   繁体   English

从Owin自托管Web服务下载大文件

[英]Download large files from Owin self-hosted web service

I am currently working on an Owin self-hosted web service that runs on my machine and that allows peers (other machines) to download files from its virtual directory with microsoft's BITS . 我目前正在研究在我的计算机上运行的Owin自托管Web服务,该服务允许对等方(其他计算机)使用Microsoft的BITS从其虚拟目录下载文件。 The downloads will work with relatively small files, but whenever I have to download large files (over 2Go) I get this error from BITS: 下载将使用相对较小的文件,但是每当我必须下载较大的文件(通过2Go)时,我都会从BITS收到此错误:

"The server does not support the necessary HTTP protocol. Background Intelligent Transfer Service (BITS) requires that the server support the Range protocol header." “服务器不支持必要的HTTP协议。后台智能传输服务(BITS)要求服务器支持Range协议标头。”

I was wondering if there was a way to enable the Range Requests in Owin or if I have to implement manually the "data chunking" in the requests I receive. 我想知道是否有一种方法可以在Owin中启用范围请求,还是必须在收到的请求中手动实现“数据分块”。 Because changing the content of every request to have the header "Accept-Ranges: bytes" doesn't seem to work (I assumed it would not magically worked, but I tried it anyway). 因为将每个请求的内容更改为具有标头“ Accept-Ranges:bytes”似乎不起作用(我以为这不会神奇地起作用,但无论如何我还是尝试了)。

I couldn't find a lot of information on what I am trying to do besides finding out how to know if a server is supporting the range requests. 除了找出如何知道服务器是否支持范围请求之外,我找不到很多我想做的事情的信息。

There was this question that seemed to look similar to mine, but was more focussed on setting the headers properly. 这个问题看起来与我的相似,但更多地集中在正确设置标题上。 It doesn't really show if/how the code splits the file before returning the response. 它并没有真正显示代码是否/如何在返回响应之前拆分文件。 There was also something about IIS, but my web service doesn't run on IIS, it runs on the client's machine and is instanciated by a windows service. IIS也有一些问题,但是我的Web服务不在IIS上运行,而是在客户端计算机上运行,​​并由Windows Service实例化。

I found a solution to my problem. 我找到了解决问题的方法。 With a little bit more research on the subject, I discovered this article which sums up really well the problem I had, which is that requests going trough ASP.NET Http Handlers do not support Range-specific requests. 通过对该主题进行更多的研究,我发现了这篇文章 ,它很好地总结了我所遇到的问题,即通过ASP.NET Http处理程序的请求不支持特定于范围的请求。 So I will have to manually implement support for the range specific requests in my web service. 因此,我将不得不在Web服务中手动实现对范围特定请求的支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM