Archived Forum Post

Index of archived forum posts

Question:

quickGetStr problem on unix (hostgator) server

Jan 29 '14 at 14:12

I must be doing something really stupid... This code fragment shows how I access two web pages on two different sites:

const char* const pszContents = http.quickGetStr (pszWebPage);
TRACE ("%s",pszContents) ;

If pszWebPage is "http://www.ransen.com/default.htm" then quickGetStr returns the contents correctly.

If pszWebPage is "http://www.dxftosvg.com/default.html" then quickGetStr returns a 404 page from the HostGator hoster.

Both pages work as they should in a browser. The first URL is on a Windows based server. The second is on a HostGator server, which is unix (I think) and is case sensitive, but apart from that I cannot see why the second call should not work.


Answer

Hello Owen,

Could it be that http://www.dxftosvg.com/default.html is some kind of .htaccess redirect? Does lastErrorText say something interesting?

Gert


Answer

Here is what the LastErrorText tells me:

ChilkatLog:
  QuickGetStr:
    DllDate: Aug 24 2012
    UnlockPrefix: etc etc
    Username: etc etc
    Architecture: Little Endian; 32-bit
    Language: Visual C++ 10.0
    VerboseLogging: 0
    VerboseLogging: 0
    QuickReq:
      url: http://www.dxftosvg.com/default.html
      QuickGetToOutput_OnExisting:
        qGet_1:
          simpleHttpRequest_3:
            httpMethod: GET
            requestUrl: http://www.dxftosvg.com/default.html
            Connecting to web server...
            httpServer: www.dxftosvg.com
            port: 80
            ConnectTimeoutMs_1: 10000
            calling ConnectSocket2
            IPV6 enabled connect with NO heartbeat.
            connectingTo: www.dxftosvg.com
            dnsCacheLookup: www.dxftosvg.com
            Resolving domain name (IPV4)
            GetHostByNameHB_ipv4: Elapsed time: 374 millisec
            myIP_1: 192.168.1.101
            myPort_1: 49673
            connect successful

Answer

Someone how knows more than me has dug deeper and here is the response he got:

HTTP/1.1 406 Not Acceptable
Date: Sat, 28 Dec 2013 17:53:24 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<head><title>Not Acceptable!</title></head><body><h1>Not 
Acceptable!</h1><p>An appropriate representation of the requested 
resource could not be found on this server. This error was generated by 
Mod_Security.</p></body></html>

He's then suggsted that: "Apparently, Hostgator is using Mod_Security that detects your request as not valid in some way. Maybe the User Agent is missing or is not standard?maybe the user agent is missing or not standard"

Should I be using a different function rather than quickGetStr?


Answer

Magic! That did the trick! Many thanks. I can only assume that HostGator has some security which rejects http requests from "non humans"


Answer

Me too. When i put url : http://www.w3.org/Protocols/. The html return correct content. But when i put http://blackforever.net/ the string html return "" (NULL) although connected successful. Anybody can help with other function ? I am using thew newest verion Jul 9 2013 in VC6.0

Thank a lot


Answer

Have you tried setting MimicIe as suggested to me halfway down this page? It worked for me...