fetch only some part of a MP4 over HTTP - http

I want to retrieve only the last x seconds of a MP4 file located on a remote http server thanks to 'Range' HTTP Header.
How can I know which bytes I need to retrieve? Is there the file structure somewhere?

Related

How to send an Audio File to a Webserver?

I want to upload a file on a client (website), then send the audio file (let's say .wav) to a web-server where it can be processed. How do I do this? What would the HTTP POST request look like?

How to act as a middleman server to add HTTP headers between client and remote server?

I have a server which acts as a middle man between an HTTP client that I don't control and a remote file hosting server I don't control. I want to expose a URL through which the client can download a chunk (specified by HTTP range headers my server provides) of a file on the remote server.
There are two important constraints here: I'd like to facilitate this partial download without having the response flow back through my server (response goes straight to client) and without writing a custom client. How can I accomplish this?
One option I tried was having my endpoint send a redirect response with the range headers set on the response, but unfortunately those do not get forwarded onto the subsequent request from the client and as a result the entire file is downloaded. Are there any other hacky tricks / network wizardry I can employ to achieve this end given the constraints?
i am also thinking about this since 5 days it's like the server give you file only when you give required header from your side and without header it will deny your request and middleman if it does get request with required header then file will be accessable through your middleman to client and you are trying to client get file from server not from your custom server which is trying to pass headers to server for your client

How Browser download files (via HTTP or FTP)

Please forgive me if it seems a silly question, I have this doubt and couldn't find the answer on the web.
How browser and any other downloader downloads a file, which protocol is working at the backend HTTP or FTP.
As we all know HTTP can be used to transfer text, which can be rendered by the browser. It can also send binary data.
Let's say I want to access a webpage at www.xyz.com/index.aspx which has a static webpage with 2 images. As we all know a total of 3 HTTP requests will be made, one for webpage and other 2 for images.
But what about other files which have a big size. I mean suppose I'm downloading an mp3/mp4 files (having link given on the webpage). So, what protocol is working at the backend HTTP or FTP.
It depends on the url :
ftp://www.example.com/bla/bla/bla01.zip
will be fetched via ftp, and
http://www.example.com/bla/bla/bla01.zip
will be fetched via http
Of course we cannot simply change http:// with ftp:// as http need an http server, and ftp need an ftp server.

How is file content sent to browser after HTTP response returns?

When initiating a file download from the browser, I would send the server a request for the file. I know that the server then returns a response with content-type either as attachment or application/octect-stream. This lets the browser know that it should initiate the file download.
What I want to know is, how is the file data sent from the server to the client once the response has already be returned? Does it use a different protocol than http? is it always streamed from the server? or is the full file content sent in the response and then the browser just downloads it onto the client machine without maintaining a connection to the remote server?
Is there a way to know when this process has finished from either the server or the client?
The content of the the file being downloaded is included in the response. Response headers are followed by an empty line and then you have actual file data.

Is there a way to decompress client's request body in nginx?

The client gzips post body, and I want the nginx decompress post body first, then passes the decompressed content to backend web server.
I can only find the way to compress response to client.
Any solution?
Thanks first!

Resources