开发者

Can you do file piping over HTTP?

开发者 https://www.devze.com 2023-03-26 05:44 出处:网络
Is it possible to pipe or stream a file over http while ot开发者_StackOverflow中文版her application is writing to that file on the server ?Yes, this is possible.

Is it possible to pipe or stream a file over http while ot开发者_StackOverflow中文版her application is writing to that file on the server ?


Yes, this is possible.

If the other application has not obtained an exclusive lock on the file, you can keep reading until you find an eof. if there is no eof, the file is still being written too.

You then would send the file over http using chunked encoding. This way you don't have to buffer the whole file before sending it.

Do you have a particular language?


Streaming can be achieved in pure HTTP via MIME type multipart/x-mixed-replace. If you're looking to do this kind of thing in a browser, be aware that it doesn't work in IE (as usual), so then you should fall back to AJAX and polling behavior.


HTTP is a request-response protocol. If a client sends a request to a server, the server deserializes the request, does some work and then sends a response. If the server chooses, it can stream any content it likes back to the caller and only close the connection once it's done.

However, the client must be aware of the fact that it'll be receiving a stream of data in the response and must be able and willing to process the incoming feed.

We built this capability into Windows Communication Foundation (WCF) to enable services to stream large blobs back to clients via HTTP as well as TCP and Named Pipes.

0

精彩评论

暂无评论...
验证码 换一张
取 消