开发者

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 c开发者_如何学运维ontent (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?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜