Exemplo n.º 1
0
Arquivo: mhttp.c Projeto: bigml/mbase
/*
 * IE: make sure timezone & time set correct on web server
 */
void mhttp_cache_headers(time_t second)
{
    /*
    char my_time[256];
    time_t now = time(NULL);
    time_t exp_date = now + second;
    time_t mod_date = now - second;
    */

    //cgiwrap_writef("Cache-Control: public, max-age=%lu\r\n", second);
    cgiwrap_writef("Cache-Control: max-age=%lu\r\n", second);

    /*
    strftime (my_time, 48, "%A, %d-%b-%Y %H:%M:%S GMT",
              gmtime (&exp_date));
    cgiwrap_writef ("Expires: %s\r\n", my_time);
    */

    //strftime (my_time, 48, "%A, %d-%b-%Y %H:%M:%S GMT",
    //          gmtime (&mod_date));
    //cgiwrap_writef ("Last-Modified: %s\r\n", my_time);
    //cgiwrap_writef ("Last-Modified: Tue, 02 Jun 2009 05:21:07 GMT\r\n");

    /*
    // Date: should return by web server
    strftime (my_time, 48, "%A, %d-%b-%Y %H:%M:%S GMT",
              gmtime (&now));
    cgiwrap_writef ("Date: %s\r\n", my_time);
    */
}
Exemplo n.º 2
0
void mjson_execute_hdf(HDF *hdf, char *cb, time_t second)
{
    if (second > 0) {
        mhttp_cache_headers(second);
    }
    
    NEOERR *err = cgiwrap_writef("Content-Type: text/html; charset=UTF-8\r\n\r\n");
    TRACE_NOK(err);

    HDF *ohdf = hdf_get_obj(hdf, PRE_OUTPUT);
    if (!ohdf) return;

    struct json_object *out = NULL;
    mjson_asm_objs(ohdf, &out);

    cgiwrap_writef("%s(%s);\n", cb, json_object_to_json_string(out));
    TRACE_NOK(err);

    json_object_put(out);
}
Exemplo n.º 3
0
Arquivo: mimg.c Projeto: adderly/cmoon
NEOERR* mimg_output(void *pic)
{
    NEOERR *err;
    
    MCS_NOT_NULLA(pic);

    gdImagePtr im = (gdImagePtr)pic;
    char *temps; int tempi;
    
    err = cgiwrap_writef("Content-Type: image/jpeg\r\n\r\n");
    if (err != STATUS_OK) return nerr_pass(err);
    
    /*
     * gdImageJpegCtx(data, gdoutctx, -1) core dump on fastcgi mode
     */
    temps = (char*) gdImageJpegPtr(im, &tempi, -1);
    cgiwrap_write(temps, tempi);
    gdImageDestroy(im);
    gdFree(temps);

    return STATUS_OK;
}