Exemplo n.º 1
0
/********************************************************
 RESPONSE METHODS
 ********************************************************/
void RestServer::send_response(Stream &_client) {
	if (server_state == RESPOND) {
		// Serial.println("__START__");

		// handle resource info/description requests
		if ((request_options & RESOURCE_REQ) == RESOURCE_REQ) {
			print_resource_description(_client);

		// handle standard GET and POST requests
		} else {
			// handle requests in JSON format
			if ((request_options & JSON_FORMAT) == JSON_FORMAT) {
				print_json(_client);
			}
			// handle HTML requests
			else if (((request_options & JSON_FORMAT) == 0)) {
				print_html(_client);
			}
		}

		// Serial.println("__END__");

		server_state = RESET;
	}
}
Exemplo n.º 2
0
static void br_html_draw_text(duc_graph *g, double x, double y, double size, char *text)
{
	struct html_backend_data *bd = g->backend_data;
	FILE *f = bd->fout;

	fprintf(f, "t('"); 
	print_html(text, f); 
	fprintf(f, "',%.0f,%.0f,%.0f);\n", size, x, y);
}
Exemplo n.º 3
0
void send_error(int errnum, const char *message) {
    if(!message || !*message)
	message = http_err_str(errnum);

    if(!is_sky()) {
        print_html(errnum, "Error", errnum, message);
    } else {
	CGI_PRINTF("Status: %d\r\nContent-Type: application/json\r\n", errnum);
        if (verb == VERB_HEAD) {
            /* workaround for old curl: it would close (instead of reusing)
             * the connection if a HEAD doesn't have Content-Length/chunked
             * encoding. And then we run out of ports due to too many
             * TIME_WAIT connections */
            CGI_PUTS("Content-Length: 0\r\n\r\n");
        } else {
            CGI_PUTS("\r\n");
            send_error_helper('{',errnum,message);
        }
    }
}
Exemplo n.º 4
0
static void generate_report(/*@notnull@*/ test_runner * runner)
/*@globals
	fileSystem,
	internalState
@*/
/*@modifies
	fileSystem,
	internalState
@*/
{

	FILE * report;

	report = fopen(runner->report, "w");

	if(report == NULL){
		exit( cannot_write(runner->report) );
	}

	print_html(runner, report);

	(void)fclose(report);
}
Exemplo n.º 5
0
void send_home(void) {
    print_html(0, SERVER_NAME, 0, NULL);
    sxi_hmac_sha1_cleanup(&hmac_ctx);
    sxi_md_cleanup(&body_ctx);
}
Exemplo n.º 6
0
void send_home(void) {
    print_html(0, SERVER_NAME, 0, NULL);
}