Shenal Silva Shenal Silva - 3 months ago 8
HTTP Question

How to get the filename from HTTP GET request

I am trying to add a modification to Axel to get the proper filename this should be done in C language.

Currently a link such as https://put.io/v2/files/49667352/download?token=851a95c6230211e2a896003048fa303a would be saved under the filename 49667352 therfore

However when downloading from the webbrowser or a download manager such as IDM it captures the filename such as movie.mp4 sent from the server after the first Get request. How can I add that implemenation with C language.

Answer

In such cases, in the response that comes from the server, there is a header called Content-Disposition. Value of this header holds some info about the file being downloaded. So, you can find the file name in this header.

An example of this header:

Content-Disposition : attachment; "movie.mp4"