Exemplo n.º 1
0
void cannot_execute(int client) {
    char *buffer = NULL;

    int bytes = asprintf(&buffer, "HTTP/1.0 500 Internal Server Error\r\n");
    send_free(client, &buffer, bytes);;

    bytes = asprintf(&buffer, "Content-type: text/html\r\n");
    send_free(client, &buffer, bytes);;

    bytes = asprintf(&buffer, "\r\n");
    send_free(client, &buffer, bytes);;

    bytes = asprintf(&buffer, "<P>Error prohibited CGI execution.\r\n");
    send_free(client, &buffer, bytes);;
}
Exemplo n.º 2
0
int check_login_via_monitor(const char* username, const char* password) {
    pstr obuf;
    msg* sm = NULL;

    char msg_buf[100 + 100 + 1];
    sprintf(msg_buf, "%s|%s", username, password);
    obuf.buf = msg_buf;
    obuf.len = strlen(msg_buf);

    send_free(mk_LoginReq_msg(&obuf));
    sm = recv_msg();

    if(sm->mtyp == MTYP_LoginResT) {
        return 1;
    } else {
        return 0;
    }

    /*
    if(sm->mtyp != MTYP_LoginResT || sm->payload->ptyp != PTYP_NUM) {
      error("check_login_via_monitor:malformed msg is received\n");
      free_msg(sm);
      return 0;
    } else {
      return !!sm->payload->pval.num;
    }
    */
}
Exemplo n.º 3
0
void bad_request(int client) {
    char *buffer = NULL;

    int bytes = asprintf(&buffer, "HTTP/1.0 400 BAD REQUEST\r\n");
    send_free(client, &buffer, bytes);;

    bytes = asprintf(&buffer, "Content-type: text/html\r\n");
    send_free(client, &buffer, bytes);;

    bytes = asprintf(&buffer, "\r\n");
    send_free(client, &buffer, bytes);;

    bytes = asprintf(&buffer, "<P>Your browser sent a bad request, ");
    send_free(client, &buffer, bytes);;

    bytes = asprintf(&buffer, "such as a POST without a Content-Length.\r\n");
    send_free(client, &buffer, bytes);;
}
Exemplo n.º 4
0
bool param_output(const char *key, const char *value, const void *obj) {
    dino_http_data_t *http = (dino_http_data_t *) obj;

    char *buffer = NULL;

    int bytes = asprintf(&buffer, "%s: %s\r\n", key, value);

    send_free(http->socket, &buffer, bytes);

    return true;
}