picohttp_demo_post_sha256_callback is never used
@@ -1129,83 +1129,3 @@ int picoquic_demo_server_callback(picoquic_cnx_t* cnx,
return ret;
}
-
-/* Sample callback used for demonstrating the callback API.
- * The transaction returns the MD5 of the posted data */
-
-typedef struct st_picohttp_demo_post_sha256_ctx_t {
- void* hash_context;
- uint8_t buf[PICOQUIC_HASH_SIZE_MAX];
-} picohttp_demo_post_ctx_t;
-
-int picohttp_demo_post_sha256_callback(picoquic_cnx_t* cnx,
- uint8_t* bytes, size_t length,
- picohttp_call_back_event_t event, picohttp_server_stream_ctx_t * stream_ctx)
-{
- int ret = 0;
- picohttp_demo_post_ctx_t* ctx = (picohttp_demo_post_ctx_t*)stream_ctx->path_callback_ctx;
-
- switch (event) {
- case picohttp_callback_get: /* Received a get command */
- break;
- case picohttp_callback_post: /* Received a post command */
- if (ctx == NULL) {
- ctx = (picohttp_demo_post_ctx_t*)malloc(sizeof(picohttp_demo_post_ctx_t));
- if (ctx == NULL) {
- /* cannot handle the stream -- TODO: reset stream? */
- return -1;
- }
- else {
- memset(ctx->buf, 0, PICOQUIC_HASH_SIZE_MAX);
- ctx->hash_context = picoquic_hash_create("SHA256");
- stream_ctx->path_callback = picohttp_demo_post_sha256_callback;
- stream_ctx->path_callback_ctx = ctx;
- }
- }
- else {
- /* unexpected. Should not have a context here */
- return -1;
- }
- break;
- case picohttp_callback_post_data: /* Data received from peer on stream N */
- /* Add data to the hash context */
- if (ctx == NULL || ctx->hash_context == NULL) {
- ret = -1;
- }
- else {
- picoquic_hash_update(bytes, length, ctx->hash_context);
- }
- break;
- case picohttp_callback_post_fin: /* All posted data have been received */
- /* Finalize the hash context */
- if (ctx == NULL || ctx->hash_context == NULL) {
- ret = -1;
- }
- else {
- picoquic_hash_finalize(ctx->buf, ctx->hash_context);
- ctx->hash_context = NULL;
- }
- break;
- case picohttp_callback_provide_data:
- /* TODO-POST: provide data. Unexpected for this specific callback. */
- ret = -1;
- break;
- case picohttp_callback_reset: /* stream is abandoned */
- stream_ctx->path_callback = NULL;
- stream_ctx->path_callback_ctx = NULL;
-
- if (ctx != NULL){
- if (ctx->hash_context != NULL) {
- picoquic_hash_finalize(ctx->buf, ctx->hash_context);
- ctx->hash_context = NULL;
- }
- free(ctx);
- }
- break;
- default:
- ret = -1;
- break;
- }
-
- return ret;
-}
\ No newline at end of file
