Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问:302跳转之后的 url 如何获取啊? #1793

Closed
noear opened this issue Nov 19, 2016 · 3 comments
Closed

请问:302跳转之后的 url 如何获取啊? #1793

noear opened this issue Nov 19, 2016 · 3 comments
Assignees
Labels

Comments

@noear
Copy link

noear commented Nov 19, 2016

同题。急!!!

@codetalks-new
Copy link

@noear 人家都看不懂你的问题.

How to get the redirected url?

@cnoon
Copy link
Member

cnoon commented Nov 20, 2016

Hi @noear,

When you get redirected, you can get the original URL from the response.request and the redirected URL from the response.response.

let redirectURLString = "https://www.apple.com/"
let urlString = "https://httpbin.org/redirect-to?url=\(redirectURLString)"

Alamofire.request(urlString).response { response in
    let originalURL = response.request?.url
    let redirectURL = response.response?.url
}

Hopefully that helps answer your question. If Google Translate utterly failed me and I didn't answer your question, please translate into English so we can better understand.

Cheers. 🍻

@cnoon cnoon closed this as completed Nov 20, 2016
@cnoon cnoon added the question label Nov 20, 2016
@cnoon cnoon self-assigned this Nov 20, 2016
@noear
Copy link
Author

noear commented Nov 20, 2016

真是太简单的;很酷!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants