diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-05-06 19:55:55 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-05-06 19:55:55 +0200 |
commit | 3285ce77d9e6a6ce9c7e97e21dc319bc3b8a07e6 (patch) | |
tree | e9e9a6203222dce16f01dae20c0c027069ae4526 /src/backend/anastasis-httpd_policy-upload.c | |
parent | 92160158232a0f7db3c438d5e9c61be3387d7d67 (diff) | |
download | anastasis-3285ce77d9e6a6ce9c7e97e21dc319bc3b8a07e6.tar.gz anastasis-3285ce77d9e6a6ce9c7e97e21dc319bc3b8a07e6.tar.bz2 anastasis-3285ce77d9e6a6ce9c7e97e21dc319bc3b8a07e6.zip |
simplify code by using latest taler_mhd_lib convenience functions
Diffstat (limited to 'src/backend/anastasis-httpd_policy-upload.c')
-rw-r--r-- | src/backend/anastasis-httpd_policy-upload.c | 93 |
1 files changed, 11 insertions, 82 deletions
diff --git a/src/backend/anastasis-httpd_policy-upload.c b/src/backend/anastasis-httpd_policy-upload.c index 8670483..c4febb2 100644 --- a/src/backend/anastasis-httpd_policy-upload.c +++ b/src/backend/anastasis-httpd_policy-upload.c @@ -662,34 +662,10 @@ AH_handler_policy_post ( hc->cc = &cleanup_ctx; puc->con = connection; - { - const char *pay_id; - - pay_id = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER); - if (NULL != pay_id) - { - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data ( - pay_id, - strlen (pay_id), - &puc->payment_identifier, - sizeof (struct ANASTASIS_PaymentSecretP))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER - " header must be a base32-encoded Payment-Secret"); - } - puc->payment_identifier_provided = true; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Policy upload started with payment identifier `%s'\n", - pay_id); - } - } + TALER_MHD_parse_request_header_auto (connection, + ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER, + &puc->payment_identifier, + puc->payment_identifier_provided); puc->account = *account_pub; /* check for meta-data */ @@ -768,28 +744,10 @@ AH_handler_policy_post ( } puc->upload_size = (size_t) len; } - { - /* Check if header contains Anastasis-Policy-Signature */ - const char *sig_s; - sig_s = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE); - if ( (NULL == sig_s) || - (GNUNET_OK != - GNUNET_STRINGS_string_to_data (sig_s, - strlen (sig_s), - &puc->account_sig, - sizeof (puc->account_sig))) ) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_ANASTASIS_POLICY_BAD_SIGNATURE, - ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE - " header must include a base32-encoded EdDSA signature"); - } - } + TALER_MHD_parse_request_header_auto_t (connection, + ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE, + &puc->account_sig); { /* Check if header contains an ETAG */ const char *etag; @@ -834,39 +792,10 @@ AH_handler_policy_post ( } } - { - const char *long_poll_timeout_ms; - - long_poll_timeout_ms = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "timeout_ms"); - if (NULL != long_poll_timeout_ms) - { - unsigned int timeout; - char dummy; - - if (1 != sscanf (long_poll_timeout_ms, - "%u%c", - &timeout, - &dummy)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - "timeout_ms (must be non-negative number)"); - } - puc->timeout - = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( - GNUNET_TIME_UNIT_MILLISECONDS, - timeout)); - } - else - { - puc->timeout = GNUNET_TIME_relative_to_absolute ( - CHECK_PAYMENT_GENERIC_TIMEOUT); - } - } + puc->timeout = GNUNET_TIME_relative_to_absolute ( + CHECK_PAYMENT_GENERIC_TIMEOUT); + TALER_MHD_parse_request_timeout (connection, + &puc->timeout); /* check if the client insists on paying */ { |