0

When recursively expanding an URL, is it safe to rely on the URL result using curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) other than the Location header (301/302 redirection)?

I found that the location URL might be relative, but the CURLINFO_EFFECTIVE_URL is always absolute. Which one is better? I'm doing recursive expanding for a URL.

Thanks!

Itay Ganor
  • 3,965
  • 3
  • 25
  • 40

1 Answers1

0

Using CURLINFO_EFFECTIVE_URL saves you some work as in the end you need to have FQDN anyway:

Location = URI-reference

The field value consists of a single URI-reference. When it has the form of a relative reference ([RFC3986], Section 4.2), the final value is computed by resolving it against the effective request URI ([RFC3986], Section 5).

https://www.rfc-editor.org/rfc/rfc7231

Community
  • 1
  • 1
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • thanks, and how can I stop my recursion? currently, It won't continue if there's no `Location` header. what does `CURLINFO_EFFECTIVE_URL` return if there's no redirection? – Itay Ganor Jun 23 '17 at 20:55