diff options
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-reserves.c | 38 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index 24b5202e..c6e7ca78 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -656,7 +656,7 @@ handle_wire_data (void *cls, { fo->fc (fo->fc_cls, hr, - NULL, + exchange->conn, NULL, NULL, GNUNET_NO); diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c b/src/backend/taler-merchant-httpd_private-post-reserves.c index abb6d0b5..0c62ce7a 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves.c @@ -85,6 +85,16 @@ struct PostReserveContext struct GNUNET_TIME_Absolute reserve_expiration; /** + * Which HTTP status should we return? + */ + unsigned int http_status; + + /** + * Which error code should we return? + */ + enum TALER_ErrorCode ec; + + /** * Are we suspended? */ bool suspended; @@ -175,14 +185,28 @@ handle_exchange (void *cls, rc->suspended = false; MHD_resume_connection (rc->connection); + if (NULL == hr) + { + rc->ec = TALER_EC_TIMEOUT; + rc->http_status = MHD_HTTP_REQUEST_TIMEOUT; + return; + } keys = TALER_EXCHANGE_get_keys (eh); - if ( (NULL != keys) && - (NULL != payto_uri) ) + if (NULL == keys) + { + rc->ec = TALER_EC_KEYS_INVALID; + rc->http_status = MHD_HTTP_FAILED_DEPENDENCY; + return; + } + if (NULL == payto_uri) { - rc->reserve_expiration - = GNUNET_TIME_relative_to_absolute (keys->reserve_closing_delay); - rc->payto_uri = GNUNET_strdup (payto_uri); + rc->ec = TALER_EC_RESERVES_POST_UNSUPPORTED_WIRE_METHOD; + rc->http_status = MHD_HTTP_CONFLICT; + return; } + rc->reserve_expiration + = GNUNET_TIME_relative_to_absolute (keys->reserve_closing_delay); + rc->payto_uri = GNUNET_strdup (payto_uri); } @@ -249,8 +273,8 @@ TMH_private_post_reserves (const struct TMH_RequestHandler *rh, if (NULL == rc->payto_uri) { return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_RESERVES_POST_UNSUPPORTED_WIRE_METHOD, + rc->http_status, + rc->ec, "Exchange does not support wire method"); } { |