login about faq

Hi!

I know chilkathttp supports retrieving JSON objects with the PostJson method. However, my query is not a JSON query but a "normal" URL containing query parameters. When trying to retrieve them with QuickGet or QuickGetStr I get the error "Failed to get response header". I believe this is because the webserver returns json rather than html so there is no header and body. However the very same URL works fine in my browser, I can see the JSON raw data there. But how do I retrieve JSON content by sending a URL with query parameters?

Thanks in advance! T.

ChilkatLog: QuickGet: DllDate: Jan 5 2012 UnlockPrefix: MYIDakHttp Username: XP-SP3:Administrator Architecture: Little Endian; 32-bit Language: ActiveX QuickReq: QuickGetToOutput_OnExisting: simpleHttpRequest_3: httpMethod: GET requestUrl: https://host.domain.org/cgi/db.pl?md5=b3fdf6e7b0aecd48ca7e4921773fb606&path=e%3Adateneigene%20dateieneigene%20downloads&filename=7z920.exe Connecting to web server... httpServer: host.domain.org port: 443 Using HTTPS. ConnectTimeoutMs_1: 20000 calling ConnectSocket2 IPV6 enabled connect with NO heartbeat. connectingTo: host.domain.org dnsCachecgiup: host.domain.org dnsCacheHit: 192.168.1.237 GetHostByNameHB_ipv4: Elapsed time: 0 millisec maxTimeMs_connect: 20000 myIP_1: 192.168.1.71 myPort_1: 2550 connect successful. clientHelloMajorMinorVersion: 3.1 buildClientHello: majorVersion: 3 minorVersion: 1 numRandomBytes: 32 sessionIdSize: 0 numCipherSuites: 10 numCompressionMethods: 1 handshakeMessageType: ServerHello handshakeMessageLen: 0x46 processHandshakeMessage: MessageType: ServerHello Processing ServerHello... ServerHello: MajorVersion: 3 MinorVersion: 1 SessionIdLen: 32 CipherSuite: RSA_WITH_AES_256_CBC_SHA CipherSuite: 00,35 CompressionMethod: 0 Queueing ServerHello message. ServerHello is OK. HandshakeQueue: MessageType: ServerHello Dequeued ServerHello message. handshakeMessageType: Certificate handshakeMessageLen: 0x293 processHandshakeMessage: MessageType: Certificate ProcessCertificates: Certificate: derSize: 653 certSubjectCN: host.domain.org certSerial: 00ACF9F99F5B44845B certIssuerCN: host.domain.org NumCertificates: 1 Queueing Certificates message... Dequeued Certificate message. handshakeMessageType: ServerHelloDone handshakeMessageLen: 0x0 processHandshakeMessage: MessageType: ServerHelloDone Queueing HelloDone message. DequeuedMessageType: ServerHelloDone OK to ServerHelloDone! No client certificate required by the server. Encrypted pre-master secret with server certificate RSA public key is OK. Sending ClientKeyExchange... Sent ClientKeyExchange message. Sending ChangeCipherSpec... Sent ChangeCipherSpec message. Derived keys. Installed new outgoing security params. Sending FINISHED message.. algorithm: aes keyLength: 256 Sent FINISHED message.. ccsProtocolType: 1 handshakeMessageType: HandshakeFinished handshakeMessageLen: 0xc processHandshakeMessage: MessageType: HandshakeFinished FinishedMsgLen: 12 Queueing Finished message. Dequeue the FINISHED message... Dequeued Finished message. Handshake completed successfully. Secure Channel Established. connectElapsedMs: 203 -- BuildGetRequest -- Not auto-adding cookies. Adding Basic Authentication Header login: username sendElapsedMs: 0 Failed to get response header

        MessageType: HandshakeFinished
        FinishedMsgLen: 12
        Queueing Finished message.
      Dequeue the FINISHED message...
      Dequeued Finished message.
      Handshake completed successfully.
      Secure Channel Established.
      connectElapsedMs: 187
      -- BuildGetRequest --
      Not auto-adding cookies.
      Adding Basic Authentication Header
      login: 999997
      sendElapsedMs: 0
      Failed to get response header
Failed.

asked Apr 04 '13 at 12:14

Torsten's gravatar image

Torsten
1233


If I understand your post- you have a page that accepts url query parameters, and based on the input your server sends JSON data, presumably as "plain text", to the browser. I couldn't get your link to work, so I used this interpretation to formulate the following example programs.

I uploaded the following to a server as test.asp

<%@LANGUAGE="JavaScript"%>

<!--#include file="inc/json.asp"-->

<%
    var testInfo = new String(Request("param1")).replace(/[^_a-z0-9]/ig , '') ,
        Obj1 = {
            int : 1 ,
            str : '1'
        } ,
        Obj2 = {
            int : 2 ,
            str : '2'
        };

    if (testInfo === 'Show_Obj1') {

        Response.Write(JSON.stringify(Obj1))

    }
    else {

            Response.Write(JSON.stringify(Obj2))

    }

%>

and ran the following as an .hta on a local machine

<script>

    var http    = new ActiveXObject("Chilkat.Http") ,
        success = http.UnlockComponent('****') ,
        html    = '';

    if (success) {

        http.ConnectTimeout = 200;
        http.HeartbeatMs    = 200;

        html = http.QuickGetStr("http://mysite.com/sandbox/test.asp");

        alert(html);

        html = http.QuickGetStr("http://mysite.com/sandbox/test.asp?param1=Show_Obj1");

        alert(html);

    }

</script>

The above responded as anticipated, so either I misunderstood your problem or the error might lie elsewhere.

And just to be clear, the following is an example of what you should see for a successful LastErrorText of this test.

ChilkatLog:

  QuickGetStr:

    DllDate: Apr 17 2012
    UnlockPrefix: ****
    Username: PC03:blaze
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 0
    QuickReq:
      url: http://mysite.com/sandbox/test.asp?param1=Show_Obj1
      QuickGetToOutput_OnExisting:
        simpleHttpRequest_3:
          httpMethod: GET
          requestUrl: http://mysite.com/sandbox/test.asp?param1=Show_Obj1
          Connecting to web server...
          httpServer: mysite.com
          port: 80
          ConnectTimeoutMs_1: 200000
          Multi-threaded hostname to IP address resolution
          Resolving domain name (IPV4/IPV6)...
          AddrInfoList:
            AddrInfo:
              ai_flags: 0
              ai_family: 2
              ai_socktype: 1
              ai_protocol: 0
              ai_addrlen: 16
              ai_canonname: (NULL)
            --AddrInfo
          --AddrInfoList
          Connecting to IPV4 address.
          ipAddress2: 173.201.148.1
          myIP_5: 10.10.1.129
          myPort_5: 57799
          connect successful (3)
          connectElapsedMs: 78
          -- BuildGetRequest --
          Not auto-adding cookies.
          sendElapsedMs: 0
          StatusCode: 200
          StatusText: OK
          Reading response body...
          readResponseElapsedMs: 920
          CompressedSize: 130
        --simpleHttpRequest_3
      --QuickGetToOutput_OnExisting
    --QuickReq
    responseSize: 19
    responseContentType: text/html
    This is a text response...
    No charset specified, assuming Windows-1252
    Converting to utf-8 charset.
    ConvertFromCodePage: 1252
    NumUtf8Bytes: 19
    Success.
  --QuickGetStr

--ChilkatLog
link

answered Apr 04 '13 at 16:44

blaze4218's gravatar image

blaze4218
86349

blaze, thanks for your answer.

After wiresharking the sessions and examining the tcp stream I found the issue was that my CGI script on the webserver did not send header info first (which is exactly what chilkats error message sais). However the CGI worked fine when called from any browser since browsers are obviously capable of retrieving a http response that does not contain any header but just plaintext. When the CGI just does "Print $message;" you'll notice that you'll be able to see "$message" in any browser with which you opened the cgis URL, but chilkathttp will not accept such (boguous?) http response since there's no header. I don't even know if headers are mandatory in http so maybe chilkat is behaving correctly and browsers just are somewhat "fault tolerant" to these responses.

I solved the issue by preceding $cgi->header just before my print $message.

link

answered Apr 05 '13 at 03:05

Torsten's gravatar image

Torsten
1233

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×35

Asked: Apr 04 '13 at 12:14

Seen: 12,280 times

Last updated: Apr 05 '13 at 03:05

powered by OSQA