forked from Telodendria/Telodendria
Rename HttpStream() to HttpServerStream() to match HttpClientStream()
This commit is contained in:
parent
ff52cc78dc
commit
65f4c90df3
10 changed files with 14 additions and 11 deletions
5
TODO.txt
5
TODO.txt
|
@ -13,11 +13,14 @@ Milestone: v0.3.0
|
||||||
|
|
||||||
[~] Stream API
|
[~] Stream API
|
||||||
[~] Implementation
|
[~] Implementation
|
||||||
[ ] Convert all HTTP code and JSON code
|
[ ] Convert all code that deals with I/O
|
||||||
[ ] Multi-output (proof of concept)
|
[ ] Multi-output (proof of concept)
|
||||||
|
[ ] Memory streams (proof of concept)
|
||||||
[ ] TLS
|
[ ] TLS
|
||||||
[ ] SOCKS
|
[ ] SOCKS
|
||||||
[x] Move/convert UtilStreamCopy()
|
[x] Move/convert UtilStreamCopy()
|
||||||
|
[ ] Io man page
|
||||||
|
[ ] Stream man page
|
||||||
[~] HTTP Client API
|
[~] HTTP Client API
|
||||||
[x] Document HttpParseHeaders()
|
[x] Document HttpParseHeaders()
|
||||||
[ ] HttpClient man page
|
[ ] HttpClient man page
|
||||||
|
|
|
@ -230,7 +230,7 @@ HttpResponseStatus(HttpServerContext * c, HttpStatus status)
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
HttpStream(HttpServerContext * c)
|
HttpServerStream(HttpServerContext * c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,7 +128,7 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
HttpResponseHeader(context, "Content-Type", "application/json");
|
HttpResponseHeader(context, "Content-Type", "application/json");
|
||||||
HttpSendHeaders(context);
|
HttpSendHeaders(context);
|
||||||
|
|
||||||
stream = HttpStream(context);
|
stream = HttpServerStream(context);
|
||||||
|
|
||||||
JsonEncode(response, stream, JSON_DEFAULT);
|
JsonEncode(response, stream, JSON_DEFAULT);
|
||||||
JsonFree(response);
|
JsonFree(response);
|
||||||
|
|
|
@ -74,7 +74,7 @@ ROUTE_IMPL(RouteLogin, args)
|
||||||
HashMapSet(response, "flows", JsonValueArray(enabledFlows));
|
HashMapSet(response, "flows", JsonValueArray(enabledFlows));
|
||||||
break;
|
break;
|
||||||
case HTTP_POST:
|
case HTTP_POST:
|
||||||
request = JsonDecode(HttpStream(args->context));
|
request = JsonDecode(HttpServerStream(args->context));
|
||||||
if (!request)
|
if (!request)
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
|
|
|
@ -63,7 +63,7 @@ ROUTE_IMPL(RouteRefresh, args)
|
||||||
return MatrixErrorCreate(M_UNRECOGNIZED);
|
return MatrixErrorCreate(M_UNRECOGNIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
request = JsonDecode(HttpStream(args->context));
|
request = JsonDecode(HttpServerStream(args->context));
|
||||||
if (!request)
|
if (!request)
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
|
|
|
@ -81,7 +81,7 @@ ROUTE_IMPL(RouteRegister, args)
|
||||||
return MatrixErrorCreate(M_UNRECOGNIZED);
|
return MatrixErrorCreate(M_UNRECOGNIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
request = JsonDecode(HttpStream(args->context));
|
request = JsonDecode(HttpServerStream(args->context));
|
||||||
if (!request)
|
if (!request)
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
ROUTE_IMPL(RouteStatic, args)
|
ROUTE_IMPL(RouteStatic, args)
|
||||||
{
|
{
|
||||||
FILE *stream = HttpStream(args->context);
|
FILE *stream = HttpServerStream(args->context);
|
||||||
char *pathPart = MATRIX_PATH_POP(args->path);
|
char *pathPart = MATRIX_PATH_POP(args->path);
|
||||||
|
|
||||||
HttpResponseHeader(args->context, "Content-Type", "text/html");
|
HttpResponseHeader(args->context, "Content-Type", "text/html");
|
||||||
|
|
|
@ -46,7 +46,7 @@ ROUTE_IMPL(RouteTokenValid, args)
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
return MatrixErrorCreate(M_UNRECOGNIZED);
|
return MatrixErrorCreate(M_UNRECOGNIZED);
|
||||||
}
|
}
|
||||||
request = JsonDecode(HttpStream(args->context));
|
request = JsonDecode(HttpServerStream(args->context));
|
||||||
if (!request)
|
if (!request)
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
|
|
|
@ -69,7 +69,7 @@ extern void
|
||||||
HttpResponseStatus(HttpServerContext *, HttpStatus);
|
HttpResponseStatus(HttpServerContext *, HttpStatus);
|
||||||
|
|
||||||
extern FILE *
|
extern FILE *
|
||||||
HttpStream(HttpServerContext *);
|
HttpServerStream(HttpServerContext *);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
HttpSendHeaders(HttpServerContext *);
|
HttpSendHeaders(HttpServerContext *);
|
||||||
|
|
|
@ -59,14 +59,14 @@ HttpHandle(HttpServerContext * cx, void *args)
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
bytes = UtilStreamCopy(HttpStream(cx), stdout);
|
bytes = UtilStreamCopy(HttpServerStream(cx), stdout);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("(%lu bytes)\n", bytes);
|
printf("(%lu bytes)\n", bytes);
|
||||||
|
|
||||||
HttpSendHeaders(cx);
|
HttpSendHeaders(cx);
|
||||||
|
|
||||||
fprintf(HttpStream(cx), "{}\n");
|
fprintf(HttpServerStream(cx), "{}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue