My parser is passed to all url addresses and .php files that can only be found. When the parser sends a request to http://www.newtender.ru/redirect.php?url=http://example.com it must understand that it is a redirection, but it must be understood by the status code and the Location header, but for some reason when the parser sends a request to http://www.newtender.ru/redirect.php?url=http://example.com server returns the status code 200 , without the Location header, why is that? when the server returns the Location header and status code 301 indicating that the server forwarded my request. In Chrome, everything works fine, monitoring via the Network tab, an example of the answer:

 Connection: keep-alive Content-Encoding: gzip Content-Length: 20 Content-Type: text/html Date: Tue, 26 Feb 2019 15:54:41 GMT location: http://example.com Server: nginx Vary: Accept-Encoding X-Powered-By: PHP/5.2.6-1+lenny16 

The parser gets this answer:

 Server:[nginx] Date:[Tue, 26 Feb 2019 15:57:38 GMT] Content-Type:[text/html; charset=UTF-8] Vary:[Accept-Encoding] X-Powered-By:[PHP/5.6.40] Connection:[keep-alive] Keep-Alive:[timeout=20] 

What is the problem and how to solve this problem?

  • There can not be a problem that you have a location instead of a standard Location ? - Ainar-G pm
  • @Ainar-G is not the problem, I already checked, the headers are the same without Location in how it would be in the format. And the status code 200, can not be a redirect status code 200 a priori. - Mothership

1 answer 1

The problem is solved by disabling redirection in http.Client{} , CheckRedirect function.

 hc := &http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, }