Http3 POST/GET example working
This commit is contained in:
+7
-3
@@ -19,10 +19,14 @@ namespace uWS {
|
||||
/* Specify application callbacks */
|
||||
us_quic_socket_context_on_stream_data(context, [](us_quic_stream_t *s, char *data, int length) {
|
||||
|
||||
// Http3ResponseData *responseData = us_quic_stream_ext(s);
|
||||
// responseData->onData(data, length);
|
||||
// we don't have a way to know EOF?
|
||||
Http3ResponseData *responseData = (Http3ResponseData *) us_quic_stream_ext(s);
|
||||
|
||||
if (responseData) {
|
||||
responseData->onData({data, length}, true);
|
||||
}
|
||||
|
||||
printf("Body length is: %d\n", length);
|
||||
//printf("Body length is: %d\n", length);
|
||||
});
|
||||
us_quic_socket_context_on_stream_open(context, [](us_quic_stream_t *s, int is_client) {
|
||||
//printf("Stream opened!\n");
|
||||
|
||||
+18
-2
@@ -29,8 +29,8 @@ namespace uWS {
|
||||
|
||||
Http3ResponseData *responseData = (Http3ResponseData *) us_quic_stream_ext((us_quic_stream_t *) this);
|
||||
|
||||
printf("Wrapper responseData is %p\n", responseData);
|
||||
printf("%s\n", responseData);
|
||||
//printf("Wrapper responseData is %p\n", responseData);
|
||||
//printf("%s\n", responseData);
|
||||
|
||||
// if not already written status then write status
|
||||
|
||||
@@ -46,6 +46,22 @@ namespace uWS {
|
||||
/* Every request has its own stream, so we conceptually serve requests like in HTTP 1.0 */
|
||||
us_quic_stream_shutdown((us_quic_stream_t *) this);
|
||||
}
|
||||
|
||||
|
||||
/* Attach handler for aborted HTTP request */
|
||||
Http3Response *onAborted(MoveOnlyFunction<void()> &&handler) {
|
||||
Http3ResponseData *responseData = (Http3ResponseData *) us_quic_stream_ext((us_quic_stream_t *) this);
|
||||
|
||||
responseData->onAborted = std::move(handler);
|
||||
return this;
|
||||
}
|
||||
|
||||
/* Attach a read handler for data sent. Will be called with FIN set true if last segment. */
|
||||
void onData(MoveOnlyFunction<void(std::string_view, bool)> &&handler) {
|
||||
Http3ResponseData *responseData = (Http3ResponseData *) us_quic_stream_ext((us_quic_stream_t *) this);
|
||||
|
||||
responseData->onData = std::move(handler);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
#ifndef UWS_H3RESPONSEDATA_H
|
||||
#define UWS_H3RESPONSEDATA_H
|
||||
|
||||
#include "MoveOnlyFunction.h"
|
||||
#include <string_view>
|
||||
|
||||
namespace uWS {
|
||||
struct Http3ResponseData {
|
||||
|
||||
|
||||
// will need onWritable
|
||||
// onData
|
||||
MoveOnlyFunction<void()> onAborted;
|
||||
MoveOnlyFunction<void(std::string_view, bool)> onData;
|
||||
|
||||
// hasWrittenStatus
|
||||
|
||||
|
||||
Reference in New Issue
Block a user