0

I am usig Delphi XE10.3 + TIdHTTP(Indy)(10.6.2) control to visit websites.

When visiting my website via Get method, I will get an exception "HTTP/1.1 406 Not Acceptable".

I am not sure whether it is a problem of my program or my website, so I try to use my program to visit another website https://www.wordpress.com and this time I will NOT get the exception.

Therefore, this is a problem of my website so I ask here.

Based on Error:406 not acceptable, "A 406 Not Acceptable HTTP error usually indicates that the content type of your webpage is not in the Accept request header that your browser sent to the webserver.", so is there a way to know what is "the content type of my website"?

Thanks

5
  • Make a request without an Accept header, or Accept: */*, and see what the Content-Type: header returned is. It'll almost certainly be text/html. I'd guess your web client is sending a strange Accept line, or it's expecting a JSON endpoint and sending Accept: application/json, or something similar. Can you remove the Accept header from your client?
    – Rup
    Oct 2, 2020 at 22:59
  • @Rup, Thank you, but my Accept is "text/html, */*". I have changed it to "*/*" and try again, but still get the same exception
    – alancc
    Oct 2, 2020 at 23:03
  • OK, I'd guess it's not the Accept header then. Is there anything in your server error logs why it's rejecting the connection? You could also try overriding the User-Agent with a browser-like User-Agent string in case your server is configured to reject scrapers somehow.
    – Rup
    Oct 2, 2020 at 23:07
  • @Rup, My user agent is "Mozilla/3.0 (compatible; Indy Library)", which value should I try to make it looks like a browser?
    – alancc
    Oct 2, 2020 at 23:10
  • 1
    @Rup, My problem is solved, I have changed the user agent to "Mozilla/3.0" and then it works.
    – alancc
    Oct 2, 2020 at 23:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.