简体   繁体   中英

Prevent downloading of a http content body

Currently I've got a web app that retrieves the URL of a mp3 on an external server, but to conserve data I'd like to check first that the page my server is retrieving is actually a redirect, not the actual content (so I can grab the URL of the mp3 and NOT the actual mp3 itself.

The external PHP script requires that json data is POSTed to it, making it hard to get the client to do it themselves.

The problem is that although the external PHP script usually redirects me to a standard URL to GET from, sometimes it returns the actual mp3 itself in the body, using up my bandwidth rather than the user's.

What would be the best solution to fix this to make me not waste my bandwidth?

Thanks.

The best solution would be to use the Http verb HEAD.

From RFC2616

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.

However, the question is, does the remote server support HEAD?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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