Sample code for 30+ languages & platforms
C

Example: Http.QuickGetSb method

Demonstrates the QuickGetSb method.

Chilkat C Downloads

C
#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttp http;
    HCkStringBuilder sb;

    success = FALSE;

    http = CkHttp_Create();

    //  Send the HTTP GET and return the content in a StringBuilder
    sb = CkStringBuilder_Create();
    success = CkHttp_QuickGetSb(http,"https://www.chilkatsoft.com/helloWorld.json",sb);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        if (CkHttp_getLastStatus(http) == 0) {
            //  Communications error.  We did not get a response.
            printf("%s\n",CkHttp_lastErrorText(http));
        }
        else {
            printf("Response status code: %d\n",CkHttp_getLastStatus(http));
            printf("Response body error text:\n");
            printf("%s\n",CkStringBuilder_getAsString(sb));
        }

        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sb);
        return;
    }

    //  The downloaded content:
    printf("%s\n",CkStringBuilder_getAsString(sb));
    printf("Success\n");


    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sb);

    }