Fix compiler errors
This commit is contained in:
Binary file not shown.
@@ -1,3 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// This is an example of how to use cHTTP to perform
|
||||
@@ -46,7 +47,7 @@ int main(void)
|
||||
);
|
||||
}
|
||||
|
||||
printf("body: %.*s\n", res->body.len, res->body.ptr);
|
||||
printf("body: %.*s\n", HTTP_UNPACK(res->body));
|
||||
|
||||
// When we are done reading from the response object
|
||||
// we must free the request's resources.
|
||||
|
||||
Binary file not shown.
@@ -1,8 +1,7 @@
|
||||
#include <http.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../http.h"
|
||||
#include <chttp.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 2) {
|
||||
|
||||
Binary file not shown.
@@ -2,9 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <http.h>
|
||||
|
||||
#define COUNT(X) (sizeof(X) / sizeof((X)[0]))
|
||||
#include <chttp.h>
|
||||
|
||||
#define BLK "\e[0;30m"
|
||||
#define RED "\e[0;31m"
|
||||
@@ -149,7 +147,7 @@ int main(int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
http_request_line(req, HTTP_METHOD_GET, start_url);
|
||||
http_request_header(req, "User-Agent: Simple crawler", -1);
|
||||
http_request_header(req, HTTP_STR("User-Agent: Simple crawler"));
|
||||
http_request_submit(req);
|
||||
|
||||
for (;;) {
|
||||
@@ -188,7 +186,7 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
|
||||
http_request_line(req, HTTP_METHOD_GET, url);
|
||||
http_request_header(req, "User-Agent: Simple crawler", -1);
|
||||
http_request_header(req, HTTP_STR("User-Agent: Simple crawler"));
|
||||
http_request_submit(req);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#define CLOSE_SOCKET close
|
||||
#endif
|
||||
|
||||
#include <http.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// This example showcases how to use the engine interface
|
||||
// to build a blocking HTTP server that works on Windows
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <mswsock.h>
|
||||
#include <http.h>
|
||||
#include <chttp.h>
|
||||
|
||||
#define MAX_CLIENTS (1<<10)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <http.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// This example shows how to set up a basic HTTP server
|
||||
|
||||
@@ -30,7 +31,7 @@ int main(void)
|
||||
HTTP_ResponseHandle res;
|
||||
|
||||
// Block until a request is available
|
||||
int ret = http_server_wait(server, &res, &res);
|
||||
int ret = http_server_wait(server, &req, &res);
|
||||
|
||||
// The wait functions returns 0 on success and -1
|
||||
// on error. By "error" I mean an unrecoverable
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
#include <http.h>
|
||||
#include <string.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// This example shows how to generate response bodies
|
||||
// using the zero-copy API.
|
||||
@@ -18,7 +19,7 @@ int main(void)
|
||||
HTTP_Request *req;
|
||||
HTTP_ResponseHandle res;
|
||||
|
||||
int ret = http_server_wait(server, &res, &res);
|
||||
int ret = http_server_wait(server, &req, &res);
|
||||
if (ret < 0) return -1;
|
||||
|
||||
http_response_status(res, 200);
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
#include <http.h>
|
||||
#include <stddef.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// This example shows how undo a response that is being built
|
||||
// when an error occurs.
|
||||
@@ -14,7 +15,7 @@ int main(void)
|
||||
HTTP_Request *req;
|
||||
HTTP_ResponseHandle res;
|
||||
|
||||
int ret = http_server_wait(server, &res, &res);
|
||||
int ret = http_server_wait(server, &req, &res);
|
||||
if (ret < 0) return -1;
|
||||
|
||||
// Say we are building a request..
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <stdbool.h>
|
||||
#include <http.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// NOTE: This example doesn't work yet!
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <stdbool.h>
|
||||
#include <http.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// This example shows how to set up an HTTPS (HTTP over TLS)
|
||||
// server.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <http.h>
|
||||
#include <chttp.h>
|
||||
|
||||
// This is an example of how to serve different websites
|
||||
// over a single HTTPS server instance.
|
||||
@@ -29,7 +29,7 @@ int main(void)
|
||||
// First, set up an HTTPS server instance with one
|
||||
// of the certificate. This will act as default certificate
|
||||
// when ecrypted connections don't target a specific domain.
|
||||
HTTP_Server *server = http_server_init(
|
||||
HTTP_Server *server = http_server_init_ex(
|
||||
HTTP_STR("127.0.0.1"), 8080, 8443,
|
||||
HTTP_STR("websiteA_cert.pem"),
|
||||
HTTP_STR("websiteA_key.pem")
|
||||
|
||||
Reference in New Issue
Block a user