我想确定短网址的长网址是什么。我曾尝试使用 http HEAD 请求,但返回的 header 字段中实际上很少包含与目标/长 url 相关的任何数据。

有没有:
1.有什么方法可以确定长网址?
2. 如果可以,可以不用下载目的地的body吗?

谢谢

最佳答案

执行 HEAD 并查找 Location header 。

% telnet bit.ly 80
Trying 168.143.173.13...
Connected to bit.ly.
Escape character is '^]'.
HEAD /cwz5Jd HTTP/1.1
Host: bit.ly

HTTP/1.1 301 Moved
Server: nginx/0.7.42
Date: Fri, 12 Mar 2010 18:37:46 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: _bit=4b9a89fa-002bd-030af-baa08fa8;domain=.bit.ly;expires=Wed Sep  8 14:37:46 2010;path=/; HttpOnly
Location: http://www.engadget.com/2010/03/12/motorola-milestone-with-android-2-1-hitting-bulgaria-by-march-20/?utm_source=twitterfeed&utm_medium=twitter
MIME-Version: 1.0
Content-Length: 404

关于cocoa-touch - 如何从短网址获取长网址,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2434881/

10-13 09:35