diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 4 | ||||
-rw-r--r-- | src/gns/plugin_rest_gns.c | 30 | ||||
-rw-r--r-- | src/identity-provider/identity_token.c | 9 | ||||
-rw-r--r-- | src/identity-provider/plugin_rest_identity_provider.c | 29 | ||||
-rw-r--r-- | src/identity/plugin_rest_identity.c | 31 | ||||
-rw-r--r-- | src/include/gnunet_jsonapi_lib.h | 37 | ||||
-rw-r--r-- | src/include/gnunet_rest_lib.h | 16 | ||||
-rw-r--r-- | src/include/gnunet_rest_plugin.h | 2 | ||||
-rw-r--r-- | src/jsonapi/Makefile.am | 1 | ||||
-rw-r--r-- | src/jsonapi/jsonapi.c | 54 | ||||
-rw-r--r-- | src/namestore/plugin_rest_namestore.c | 68 | ||||
-rw-r--r-- | src/rest/gnunet-rest-server.c | 8 | ||||
-rw-r--r-- | src/rest/rest.c | 6 |
13 files changed, 218 insertions, 77 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 6793d6f5c..7ab8843bb 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -2522,7 +2522,7 @@ do_s5r_read (void *cls) | |||
2522 | s5r->sock, | 2522 | s5r->sock, |
2523 | &do_s5r_read, s5r); | 2523 | &do_s5r_read, s5r); |
2524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2525 | "Processing %u bytes of socks data in state %d\n", | 2525 | "Processing %zu bytes of socks data in state %d\n", |
2526 | s5r->rbuf_len, | 2526 | s5r->rbuf_len, |
2527 | s5r->state); | 2527 | s5r->state); |
2528 | switch (s5r->state) | 2528 | switch (s5r->state) |
@@ -2943,7 +2943,7 @@ run_cont () | |||
2943 | return; | 2943 | return; |
2944 | } | 2944 | } |
2945 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2945 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2946 | "Proxy listens on port %u\n", | 2946 | "Proxy listens on port %lu\n", |
2947 | port); | 2947 | port); |
2948 | 2948 | ||
2949 | /* start MHD daemon for HTTP */ | 2949 | /* start MHD daemon for HTTP */ |
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c index 91a091f2e..718a9b29b 100644 --- a/src/gns/plugin_rest_gns.c +++ b/src/gns/plugin_rest_gns.c | |||
@@ -77,6 +77,11 @@ struct LookupHandle | |||
77 | struct GNUNET_GNS_LookupRequest *lookup_request; | 77 | struct GNUNET_GNS_LookupRequest *lookup_request; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Handle to rest request | ||
81 | */ | ||
82 | struct GNUNET_REST_RequestHandle *rest_handle; | ||
83 | |||
84 | /** | ||
80 | * Lookup an ego with the identity service. | 85 | * Lookup an ego with the identity service. |
81 | */ | 86 | */ |
82 | struct GNUNET_IDENTITY_EgoLookup *el; | 87 | struct GNUNET_IDENTITY_EgoLookup *el; |
@@ -153,6 +158,11 @@ struct LookupHandle | |||
153 | */ | 158 | */ |
154 | struct GNUNET_CRYPTO_EcdsaPrivateKey shorten_key; | 159 | struct GNUNET_CRYPTO_EcdsaPrivateKey shorten_key; |
155 | 160 | ||
161 | /** | ||
162 | * HTTP response code | ||
163 | */ | ||
164 | int response_code; | ||
165 | |||
156 | }; | 166 | }; |
157 | 167 | ||
158 | 168 | ||
@@ -218,7 +228,7 @@ do_error (void *cls) | |||
218 | struct MHD_Response *resp; | 228 | struct MHD_Response *resp; |
219 | 229 | ||
220 | resp = GNUNET_REST_create_json_response (NULL); | 230 | resp = GNUNET_REST_create_json_response (NULL); |
221 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); | 231 | handle->proc (handle->proc_cls, resp, handle->response_code); |
222 | cleanup_handle (handle); | 232 | cleanup_handle (handle); |
223 | } | 233 | } |
224 | 234 | ||
@@ -505,7 +515,7 @@ parse_url (const char *url, struct LookupHandle *handle) | |||
505 | } | 515 | } |
506 | 516 | ||
507 | static void | 517 | static void |
508 | get_gns_cont (struct RestConnectionDataHandle *conndata_handle, | 518 | get_gns_cont (struct GNUNET_REST_RequestHandle *conndata_handle, |
509 | const char* url, | 519 | const char* url, |
510 | void *cls) | 520 | void *cls) |
511 | { | 521 | { |
@@ -621,7 +631,7 @@ get_gns_cont (struct RestConnectionDataHandle *conndata_handle, | |||
621 | * @param handle the lookup handle | 631 | * @param handle the lookup handle |
622 | */ | 632 | */ |
623 | static void | 633 | static void |
624 | options_cont (struct RestConnectionDataHandle *con_handle, | 634 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, |
625 | const char* url, | 635 | const char* url, |
626 | void *cls) | 636 | void *cls) |
627 | { | 637 | { |
@@ -652,24 +662,32 @@ options_cont (struct RestConnectionDataHandle *con_handle, | |||
652 | * @return GNUNET_OK if request accepted | 662 | * @return GNUNET_OK if request accepted |
653 | */ | 663 | */ |
654 | static void | 664 | static void |
655 | rest_gns_process_request(struct RestConnectionDataHandle *conndata_handle, | 665 | rest_gns_process_request(struct GNUNET_REST_RequestHandle *conndata_handle, |
656 | GNUNET_REST_ResultProcessor proc, | 666 | GNUNET_REST_ResultProcessor proc, |
657 | void *proc_cls) | 667 | void *proc_cls) |
658 | { | 668 | { |
659 | struct LookupHandle *handle = GNUNET_new (struct LookupHandle); | 669 | struct LookupHandle *handle = GNUNET_new (struct LookupHandle); |
670 | struct GNUNET_REST_RequestHandlerError err; | ||
660 | 671 | ||
661 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 672 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
662 | handle->proc_cls = proc_cls; | 673 | handle->proc_cls = proc_cls; |
663 | handle->proc = proc; | 674 | handle->proc = proc; |
675 | handle->rest_handle = conndata_handle; | ||
664 | 676 | ||
665 | static const struct GNUNET_REST_RestConnectionHandler handlers[] = { | 677 | static const struct GNUNET_REST_RequestHandler handlers[] = { |
666 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_GNS, &get_gns_cont}, | 678 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_GNS, &get_gns_cont}, |
667 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_GNS, &options_cont}, | 679 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_GNS, &options_cont}, |
668 | GNUNET_REST_HANDLER_END | 680 | GNUNET_REST_HANDLER_END |
669 | }; | 681 | }; |
670 | 682 | ||
671 | if (GNUNET_NO == GNUNET_REST_handle_request (conndata_handle, handlers, handle)) | 683 | if (GNUNET_NO == GNUNET_JSONAPI_handle_request (conndata_handle, |
684 | handlers, | ||
685 | &err, | ||
686 | handle)) | ||
687 | { | ||
688 | handle->response_code = err.error_code; | ||
672 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 689 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
690 | } | ||
673 | } | 691 | } |
674 | 692 | ||
675 | 693 | ||
diff --git a/src/identity-provider/identity_token.c b/src/identity-provider/identity_token.c index 3bed6962e..8a90138ec 100644 --- a/src/identity-provider/identity_token.c +++ b/src/identity-provider/identity_token.c | |||
@@ -98,7 +98,10 @@ decrypt_str_ecdhe (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key, | |||
98 | &enc_key, | 98 | &enc_key, |
99 | &enc_iv, | 99 | &enc_iv, |
100 | str_buf); | 100 | str_buf); |
101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted bytes: %d Expected bytes: %d\n", str_size, cyphertext_len); | 101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
102 | "Decrypted bytes: %zd Expected bytes: %zd\n", | ||
103 | str_size, | ||
104 | cyphertext_len); | ||
102 | if (-1 == str_size) | 105 | if (-1 == str_size) |
103 | { | 106 | { |
104 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ECDH invalid\n"); | 107 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ECDH invalid\n"); |
@@ -172,14 +175,14 @@ encrypt_str_ecdhe (const char *plaintext, | |||
172 | pub_key, | 175 | pub_key, |
173 | &new_key_hash)); | 176 | &new_key_hash)); |
174 | create_sym_key_from_ecdh(&new_key_hash, &skey, &iv); | 177 | create_sym_key_from_ecdh(&new_key_hash, &skey, &iv); |
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting string %s\n (len=%d)", | 178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting string %s\n (len=%zd)", |
176 | plaintext, | 179 | plaintext, |
177 | strlen (plaintext)); | 180 | strlen (plaintext)); |
178 | enc_size = GNUNET_CRYPTO_symmetric_encrypt (plaintext, | 181 | enc_size = GNUNET_CRYPTO_symmetric_encrypt (plaintext, |
179 | strlen (plaintext), | 182 | strlen (plaintext), |
180 | &skey, &iv, | 183 | &skey, &iv, |
181 | *cyphertext); | 184 | *cyphertext); |
182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted (len=%d)", enc_size); | 185 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted (len=%zd)", enc_size); |
183 | return GNUNET_OK; | 186 | return GNUNET_OK; |
184 | } | 187 | } |
185 | 188 | ||
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c index 1f03713ea..1e1878cad 100644 --- a/src/identity-provider/plugin_rest_identity_provider.c +++ b/src/identity-provider/plugin_rest_identity_provider.c | |||
@@ -199,7 +199,7 @@ struct RequestHandle | |||
199 | /** | 199 | /** |
200 | * Handle to the rest connection | 200 | * Handle to the rest connection |
201 | */ | 201 | */ |
202 | struct RestConnectionDataHandle *conndata_handle; | 202 | struct GNUNET_REST_RequestHandle *conndata_handle; |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * The processing state | 205 | * The processing state |
@@ -272,6 +272,11 @@ struct RequestHandle | |||
272 | char *emsg; | 272 | char *emsg; |
273 | 273 | ||
274 | /** | 274 | /** |
275 | * Reponse code | ||
276 | */ | ||
277 | int response_code; | ||
278 | |||
279 | /** | ||
275 | * Response object | 280 | * Response object |
276 | */ | 281 | */ |
277 | struct GNUNET_JSONAPI_Object *resp_object; | 282 | struct GNUNET_JSONAPI_Object *resp_object; |
@@ -337,7 +342,7 @@ do_error (void *cls) | |||
337 | "{Error while processing request: %s}", | 342 | "{Error while processing request: %s}", |
338 | handle->emsg); | 343 | handle->emsg); |
339 | resp = GNUNET_REST_create_json_response (json_error); | 344 | resp = GNUNET_REST_create_json_response (json_error); |
340 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); | 345 | handle->proc (handle->proc_cls, resp, handle->response_code); |
341 | cleanup_handle (handle); | 346 | cleanup_handle (handle); |
342 | GNUNET_free (json_error); | 347 | GNUNET_free (json_error); |
343 | } | 348 | } |
@@ -434,7 +439,7 @@ token_creat_cont (void *cls, | |||
434 | * @param cls the request handle | 439 | * @param cls the request handle |
435 | */ | 440 | */ |
436 | static void | 441 | static void |
437 | issue_token_cont (struct RestConnectionDataHandle *con, | 442 | issue_token_cont (struct GNUNET_REST_RequestHandle *con, |
438 | const char *url, | 443 | const char *url, |
439 | void *cls) | 444 | void *cls) |
440 | { | 445 | { |
@@ -730,7 +735,7 @@ token_collect (void *cls, | |||
730 | * @param cls the RequestHandle | 735 | * @param cls the RequestHandle |
731 | */ | 736 | */ |
732 | static void | 737 | static void |
733 | list_token_cont (struct RestConnectionDataHandle *con_handle, | 738 | list_token_cont (struct GNUNET_REST_RequestHandle *con_handle, |
734 | const char* url, | 739 | const char* url, |
735 | void *cls) | 740 | void *cls) |
736 | { | 741 | { |
@@ -919,7 +924,7 @@ exchange_token_ticket_cb (void *cls, | |||
919 | * @param cls the RequestHandle | 924 | * @param cls the RequestHandle |
920 | */ | 925 | */ |
921 | static void | 926 | static void |
922 | exchange_token_ticket_cont (struct RestConnectionDataHandle *con_handle, | 927 | exchange_token_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, |
923 | const char* url, | 928 | const char* url, |
924 | void *cls) | 929 | void *cls) |
925 | { | 930 | { |
@@ -940,7 +945,7 @@ exchange_token_ticket_cont (struct RestConnectionDataHandle *con_handle, | |||
940 | * @param cls the RequestHandle | 945 | * @param cls the RequestHandle |
941 | */ | 946 | */ |
942 | static void | 947 | static void |
943 | options_cont (struct RestConnectionDataHandle *con_handle, | 948 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, |
944 | const char* url, | 949 | const char* url, |
945 | void *cls) | 950 | void *cls) |
946 | { | 951 | { |
@@ -965,7 +970,8 @@ options_cont (struct RestConnectionDataHandle *con_handle, | |||
965 | static void | 970 | static void |
966 | init_cont (struct RequestHandle *handle) | 971 | init_cont (struct RequestHandle *handle) |
967 | { | 972 | { |
968 | static const struct GNUNET_REST_RestConnectionHandler handlers[] = { | 973 | struct GNUNET_REST_RequestHandlerError err; |
974 | static const struct GNUNET_REST_RequestHandler handlers[] = { | ||
969 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TOKEN_ISSUE, &issue_token_cont}, | 975 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TOKEN_ISSUE, &issue_token_cont}, |
970 | //{MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_TOKEN_CHECK, &check_token_cont}, | 976 | //{MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_TOKEN_CHECK, &check_token_cont}, |
971 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PROVIDER, &list_token_cont}, | 977 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PROVIDER, &list_token_cont}, |
@@ -974,9 +980,12 @@ init_cont (struct RequestHandle *handle) | |||
974 | GNUNET_REST_HANDLER_END | 980 | GNUNET_REST_HANDLER_END |
975 | }; | 981 | }; |
976 | 982 | ||
977 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, handlers, handle)) | 983 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, |
984 | handlers, | ||
985 | &err, | ||
986 | handle)) | ||
978 | { | 987 | { |
979 | handle->emsg = GNUNET_strdup ("Request unsupported"); | 988 | handle->response_code = err.error_code; |
980 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 989 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
981 | } | 990 | } |
982 | } | 991 | } |
@@ -1054,7 +1063,7 @@ list_ego (void *cls, | |||
1054 | * @return GNUNET_OK if request accepted | 1063 | * @return GNUNET_OK if request accepted |
1055 | */ | 1064 | */ |
1056 | static void | 1065 | static void |
1057 | rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | 1066 | rest_identity_process_request(struct GNUNET_REST_RequestHandle *conndata_handle, |
1058 | GNUNET_REST_ResultProcessor proc, | 1067 | GNUNET_REST_ResultProcessor proc, |
1059 | void *proc_cls) | 1068 | void *proc_cls) |
1060 | { | 1069 | { |
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index 10836f103..4a2429a9c 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -146,7 +146,12 @@ struct RequestHandle | |||
146 | /** | 146 | /** |
147 | * Handle to the rest connection | 147 | * Handle to the rest connection |
148 | */ | 148 | */ |
149 | struct RestConnectionDataHandle *conndata_handle; | 149 | struct GNUNET_REST_RequestHandle *conndata_handle; |
150 | |||
151 | /** | ||
152 | * response code | ||
153 | */ | ||
154 | int response_code; | ||
150 | 155 | ||
151 | /** | 156 | /** |
152 | * The processing state | 157 | * The processing state |
@@ -276,7 +281,7 @@ do_error (void *cls) | |||
276 | resp = GNUNET_REST_create_json_response (json_error); | 281 | resp = GNUNET_REST_create_json_response (json_error); |
277 | handle->proc (handle->proc_cls, | 282 | handle->proc (handle->proc_cls, |
278 | resp, | 283 | resp, |
279 | MHD_HTTP_BAD_REQUEST); | 284 | handle->response_code); |
280 | cleanup_handle (handle); | 285 | cleanup_handle (handle); |
281 | GNUNET_free (json_error); | 286 | GNUNET_free (json_error); |
282 | } | 287 | } |
@@ -348,7 +353,7 @@ get_ego_for_subsys (void *cls, | |||
348 | * @param cls the request handle | 353 | * @param cls the request handle |
349 | */ | 354 | */ |
350 | static void | 355 | static void |
351 | ego_info_response (struct RestConnectionDataHandle *con, | 356 | ego_info_response (struct GNUNET_REST_RequestHandle *con, |
352 | const char *url, | 357 | const char *url, |
353 | void *cls) | 358 | void *cls) |
354 | { | 359 | { |
@@ -477,7 +482,7 @@ do_finished (void *cls, const char *emsg) | |||
477 | * @param cls request handle | 482 | * @param cls request handle |
478 | */ | 483 | */ |
479 | static void | 484 | static void |
480 | ego_create_cont (struct RestConnectionDataHandle *con, | 485 | ego_create_cont (struct GNUNET_REST_RequestHandle *con, |
481 | const char *url, | 486 | const char *url, |
482 | void *cls) | 487 | void *cls) |
483 | { | 488 | { |
@@ -566,7 +571,7 @@ ego_create_cont (struct RestConnectionDataHandle *con, | |||
566 | * @param cls the RequestHandle | 571 | * @param cls the RequestHandle |
567 | */ | 572 | */ |
568 | static void | 573 | static void |
569 | ego_edit_cont (struct RestConnectionDataHandle *con, | 574 | ego_edit_cont (struct GNUNET_REST_RequestHandle *con, |
570 | const char *url, | 575 | const char *url, |
571 | void *cls) | 576 | void *cls) |
572 | { | 577 | { |
@@ -696,7 +701,7 @@ ego_edit_cont (struct RestConnectionDataHandle *con, | |||
696 | } | 701 | } |
697 | 702 | ||
698 | void | 703 | void |
699 | ego_delete_cont (struct RestConnectionDataHandle *con_handle, | 704 | ego_delete_cont (struct GNUNET_REST_RequestHandle *con_handle, |
700 | const char* url, | 705 | const char* url, |
701 | void *cls) | 706 | void *cls) |
702 | { | 707 | { |
@@ -746,7 +751,7 @@ ego_delete_cont (struct RestConnectionDataHandle *con_handle, | |||
746 | * @param cls the RequestHandle | 751 | * @param cls the RequestHandle |
747 | */ | 752 | */ |
748 | static void | 753 | static void |
749 | options_cont (struct RestConnectionDataHandle *con_handle, | 754 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, |
750 | const char* url, | 755 | const char* url, |
751 | void *cls) | 756 | void *cls) |
752 | { | 757 | { |
@@ -771,7 +776,8 @@ options_cont (struct RestConnectionDataHandle *con_handle, | |||
771 | static void | 776 | static void |
772 | init_cont (struct RequestHandle *handle) | 777 | init_cont (struct RequestHandle *handle) |
773 | { | 778 | { |
774 | static const struct GNUNET_REST_RestConnectionHandler handlers[] = { | 779 | struct GNUNET_REST_RequestHandlerError err; |
780 | static const struct GNUNET_REST_RequestHandler handlers[] = { | ||
775 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_info_response}, | 781 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_info_response}, |
776 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont}, | 782 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont}, |
777 | {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont}, | 783 | {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont}, |
@@ -780,9 +786,12 @@ init_cont (struct RequestHandle *handle) | |||
780 | GNUNET_REST_HANDLER_END | 786 | GNUNET_REST_HANDLER_END |
781 | }; | 787 | }; |
782 | 788 | ||
783 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, handlers, handle)) | 789 | if (GNUNET_NO == GNUNET_JSONAPI_handle_request (handle->conndata_handle, |
790 | handlers, | ||
791 | &err, | ||
792 | handle)) | ||
784 | { | 793 | { |
785 | handle->emsg = GNUNET_strdup ("Request unsupported"); | 794 | handle->response_code = err.error_code; |
786 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 795 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
787 | } | 796 | } |
788 | } | 797 | } |
@@ -860,7 +869,7 @@ list_ego (void *cls, | |||
860 | * @return GNUNET_OK if request accepted | 869 | * @return GNUNET_OK if request accepted |
861 | */ | 870 | */ |
862 | static void | 871 | static void |
863 | rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | 872 | rest_identity_process_request(struct GNUNET_REST_RequestHandle *conndata_handle, |
864 | GNUNET_REST_ResultProcessor proc, | 873 | GNUNET_REST_ResultProcessor proc, |
865 | void *proc_cls) | 874 | void *proc_cls) |
866 | { | 875 | { |
diff --git a/src/include/gnunet_jsonapi_lib.h b/src/include/gnunet_jsonapi_lib.h index 1e540f6b6..d4556c174 100644 --- a/src/include/gnunet_jsonapi_lib.h +++ b/src/include/gnunet_jsonapi_lib.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #define GNUNET_JSONAPI_LIB_H | 22 | #define GNUNET_JSONAPI_LIB_H |
23 | 23 | ||
24 | #include "gnunet_util_lib.h" | 24 | #include "gnunet_util_lib.h" |
25 | #include "gnunet_rest_lib.h" | ||
25 | #include "gnunet_json_lib.h" | 26 | #include "gnunet_json_lib.h" |
26 | 27 | ||
27 | 28 | ||
@@ -200,5 +201,41 @@ GNUNET_JSONAPI_data_serialize (const struct GNUNET_JSONAPI_Object *resp, | |||
200 | */ | 201 | */ |
201 | json_t* | 202 | json_t* |
202 | GNUNET_JSONAPI_resource_get_id (const struct GNUNET_JSONAPI_Resource *resource); | 203 | GNUNET_JSONAPI_resource_get_id (const struct GNUNET_JSONAPI_Resource *resource); |
204 | |||
205 | |||
203 | /* end of gnunet_jsonapi_lib.h */ | 206 | /* end of gnunet_jsonapi_lib.h */ |
207 | |||
208 | /** | ||
209 | * Check rest request for validity | ||
210 | * | ||
211 | * @param req handle to the request | ||
212 | * @return GNUNET_OK if valid | ||
213 | */ | ||
214 | int | ||
215 | GNUNET_JSONAPI_check_request_acceptable (struct GNUNET_REST_RequestHandle *req); | ||
216 | |||
217 | /** | ||
218 | * Check rest request for validity | ||
219 | * | ||
220 | * @param req handle to the request | ||
221 | * @return GNUNET_OK if valid | ||
222 | */ | ||
223 | int | ||
224 | GNUNET_JSONAPI_check_request_supported (struct GNUNET_REST_RequestHandle *req); | ||
225 | |||
226 | |||
227 | /** | ||
228 | * Handle jsonapi rest request. Checks request headers for jsonapi compliance | ||
229 | * | ||
230 | * @param req rest request handle | ||
231 | * @param handler rest request handlers | ||
232 | * @param cls closure | ||
233 | * @return GNUNET_OK if successful | ||
234 | */ | ||
235 | int | ||
236 | GNUNET_JSONAPI_handle_request (struct GNUNET_REST_RequestHandle *req, | ||
237 | const struct GNUNET_REST_RequestHandler *handlers, | ||
238 | struct GNUNET_REST_RequestHandlerError *err, | ||
239 | void *cls); | ||
240 | |||
204 | #endif | 241 | #endif |
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h index ea254cc9b..ecd825f3f 100644 --- a/src/include/gnunet_rest_lib.h +++ b/src/include/gnunet_rest_lib.h | |||
@@ -37,17 +37,22 @@ | |||
37 | 37 | ||
38 | #define GNUNET_REST_HANDLER_END {NULL, NULL, NULL} | 38 | #define GNUNET_REST_HANDLER_END {NULL, NULL, NULL} |
39 | 39 | ||
40 | struct RestConnectionDataHandle | 40 | struct GNUNET_REST_RequestHandle |
41 | { | 41 | { |
42 | struct GNUNET_CONTAINER_MultiHashMap *url_param_map; | 42 | struct GNUNET_CONTAINER_MultiHashMap *url_param_map; |
43 | const char *method; | 43 | const char *method; |
44 | const char *url; | 44 | const char *url; |
45 | const char *data; | 45 | const char *data; |
46 | size_t data_size; | 46 | size_t data_size; |
47 | }; | ||
47 | 48 | ||
49 | struct GNUNET_REST_RequestHandlerError | ||
50 | { | ||
51 | int error_code; | ||
52 | char* error_text; | ||
48 | }; | 53 | }; |
49 | 54 | ||
50 | struct GNUNET_REST_RestConnectionHandler | 55 | struct GNUNET_REST_RequestHandler |
51 | { | 56 | { |
52 | /** | 57 | /** |
53 | * Http method to handle | 58 | * Http method to handle |
@@ -62,7 +67,7 @@ struct GNUNET_REST_RestConnectionHandler | |||
62 | /** | 67 | /** |
63 | * callback handler | 68 | * callback handler |
64 | */ | 69 | */ |
65 | void (*proc) (struct RestConnectionDataHandle *handle, | 70 | void (*proc) (struct GNUNET_REST_RequestHandle *handle, |
66 | const char *url, | 71 | const char *url, |
67 | void *cls); | 72 | void *cls); |
68 | 73 | ||
@@ -101,8 +106,9 @@ GNUNET_REST_create_json_response (const char *data); | |||
101 | 106 | ||
102 | 107 | ||
103 | int | 108 | int |
104 | GNUNET_REST_handle_request (struct RestConnectionDataHandle *conn, | 109 | GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn, |
105 | const struct GNUNET_REST_RestConnectionHandler *handlers, | 110 | const struct GNUNET_REST_RequestHandler *handlers, |
111 | struct GNUNET_REST_RequestHandlerError *err, | ||
106 | void *cls); | 112 | void *cls); |
107 | 113 | ||
108 | 114 | ||
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h index 6685cdec2..ecd5f66f1 100644 --- a/src/include/gnunet_rest_plugin.h +++ b/src/include/gnunet_rest_plugin.h | |||
@@ -71,7 +71,7 @@ struct GNUNET_REST_Plugin | |||
71 | * @param proc the callback for result | 71 | * @param proc the callback for result |
72 | * @param proc_cls closure for callback | 72 | * @param proc_cls closure for callback |
73 | */ | 73 | */ |
74 | void (*process_request) (struct RestConnectionDataHandle *handle, | 74 | void (*process_request) (struct GNUNET_REST_RequestHandle *handle, |
75 | GNUNET_REST_ResultProcessor proc, | 75 | GNUNET_REST_ResultProcessor proc, |
76 | void *proc_cls); | 76 | void *proc_cls); |
77 | 77 | ||
diff --git a/src/jsonapi/Makefile.am b/src/jsonapi/Makefile.am index 8a702440d..bcd4172c6 100644 --- a/src/jsonapi/Makefile.am +++ b/src/jsonapi/Makefile.am | |||
@@ -17,6 +17,7 @@ libgnunetjsonapi_la_SOURCES = \ | |||
17 | libgnunetjsonapi_la_LIBADD = \ | 17 | libgnunetjsonapi_la_LIBADD = \ |
18 | $(top_builddir)/src/util/libgnunetutil.la \ | 18 | $(top_builddir)/src/util/libgnunetutil.la \ |
19 | $(top_builddir)/src/json/libgnunetjson.la \ | 19 | $(top_builddir)/src/json/libgnunetjson.la \ |
20 | $(top_builddir)/src/rest/libgnunetrest.la \ | ||
20 | -ljansson \ | 21 | -ljansson \ |
21 | $(XLIB) | 22 | $(XLIB) |
22 | 23 | ||
diff --git a/src/jsonapi/jsonapi.c b/src/jsonapi/jsonapi.c index 6bd03e0ec..b648590e5 100644 --- a/src/jsonapi/jsonapi.c +++ b/src/jsonapi/jsonapi.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | #include "platform.h" | 21 | #include "platform.h" |
22 | #include "gnunet_json_lib.h" | 22 | #include "gnunet_json_lib.h" |
23 | #include "gnunet_rest_lib.h" | ||
23 | 24 | ||
24 | #define GNUNET_JSONAPI_KEY_DATA "data" | 25 | #define GNUNET_JSONAPI_KEY_DATA "data" |
25 | 26 | ||
@@ -476,3 +477,56 @@ GNUNET_JSON_spec_jsonapi (struct GNUNET_JSONAPI_Object **jsonapi_object) | |||
476 | *jsonapi_object = NULL; | 477 | *jsonapi_object = NULL; |
477 | return ret; | 478 | return ret; |
478 | } | 479 | } |
480 | |||
481 | /** | ||
482 | * Check rest request for validity | ||
483 | * | ||
484 | * @param req handle to the request | ||
485 | * @return GNUNET_OK if valid | ||
486 | */ | ||
487 | int | ||
488 | GNUNET_JSONAPI_check_request_acceptable (struct GNUNET_REST_RequestHandle *req) | ||
489 | { | ||
490 | //TODO | ||
491 | return GNUNET_OK; | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * Check rest request for validity | ||
496 | * | ||
497 | * @param req handle to the request | ||
498 | * @return GNUNET_OK if valid | ||
499 | */ | ||
500 | int | ||
501 | GNUNET_JSONAPI_check_request_supported (struct GNUNET_REST_RequestHandle *req) | ||
502 | { | ||
503 | //TODO | ||
504 | return GNUNET_OK; | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Handle jsonapi rest request. Checks request headers for jsonapi compliance | ||
509 | * | ||
510 | * @param req rest request handle | ||
511 | * @param handler rest request handlers | ||
512 | * @param cls closure | ||
513 | * @return GNUNET_OK if successful | ||
514 | */ | ||
515 | int | ||
516 | GNUNET_JSONAPI_handle_request (struct GNUNET_REST_RequestHandle *handle, | ||
517 | const struct GNUNET_REST_RequestHandler *handlers, | ||
518 | struct GNUNET_REST_RequestHandlerError *err, | ||
519 | void *cls) | ||
520 | { | ||
521 | if (GNUNET_OK != GNUNET_JSONAPI_check_request_acceptable (handle)) | ||
522 | { | ||
523 | err->error_code = MHD_HTTP_NOT_ACCEPTABLE; | ||
524 | return GNUNET_SYSERR; | ||
525 | } | ||
526 | if (GNUNET_OK != GNUNET_JSONAPI_check_request_supported (handle)) | ||
527 | { | ||
528 | err->error_code = MHD_HTTP_UNSUPPORTED_MEDIA_TYPE; | ||
529 | return GNUNET_SYSERR; | ||
530 | } | ||
531 | return GNUNET_REST_handle_request (handle, handlers, err, cls); | ||
532 | } | ||
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index c47a6a3c8..76a1126a5 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c | |||
@@ -111,7 +111,7 @@ struct RequestHandle | |||
111 | /** | 111 | /** |
112 | * Rest connection | 112 | * Rest connection |
113 | */ | 113 | */ |
114 | struct RestConnectionDataHandle *conndata_handle; | 114 | struct GNUNET_REST_RequestHandle *rest_handle; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * Handle to GNS service. | 117 | * Handle to GNS service. |
@@ -224,19 +224,14 @@ struct RequestHandle | |||
224 | char *url; | 224 | char *url; |
225 | 225 | ||
226 | /** | 226 | /** |
227 | * The data from the REST request | 227 | * Cfg |
228 | */ | 228 | */ |
229 | const char* data; | 229 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
230 | 230 | ||
231 | /** | 231 | /** |
232 | * the length of the REST data | 232 | * HTTP response code |
233 | */ | 233 | */ |
234 | size_t data_size; | 234 | int response_code; |
235 | |||
236 | /** | ||
237 | * Cfg | ||
238 | */ | ||
239 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
240 | 235 | ||
241 | }; | 236 | }; |
242 | 237 | ||
@@ -364,7 +359,7 @@ do_error (void *cls) | |||
364 | struct RequestHandle *handle = cls; | 359 | struct RequestHandle *handle = cls; |
365 | struct MHD_Response *resp = GNUNET_REST_create_json_response (NULL); | 360 | struct MHD_Response *resp = GNUNET_REST_create_json_response (NULL); |
366 | 361 | ||
367 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); | 362 | handle->proc (handle->proc_cls, resp, handle->response_code); |
368 | cleanup_handle (handle); | 363 | cleanup_handle (handle); |
369 | } | 364 | } |
370 | 365 | ||
@@ -596,7 +591,7 @@ del_cont (void *cls, | |||
596 | } | 591 | } |
597 | 592 | ||
598 | static void | 593 | static void |
599 | namestore_delete_cont (struct RestConnectionDataHandle *con, | 594 | namestore_delete_cont (struct GNUNET_REST_RequestHandle *con, |
600 | const char *url, | 595 | const char *url, |
601 | void *cls) | 596 | void *cls) |
602 | { | 597 | { |
@@ -718,7 +713,7 @@ json_to_gnsrecord (const json_t *records_json, | |||
718 | } | 713 | } |
719 | 714 | ||
720 | static void | 715 | static void |
721 | namestore_create_cont (struct RestConnectionDataHandle *con, | 716 | namestore_create_cont (struct GNUNET_REST_RequestHandle *con, |
722 | const char *url, | 717 | const char *url, |
723 | void *cls) | 718 | void *cls) |
724 | { | 719 | { |
@@ -728,7 +723,7 @@ namestore_create_cont (struct RestConnectionDataHandle *con, | |||
728 | struct GNUNET_JSONAPI_Resource *json_res; | 723 | struct GNUNET_JSONAPI_Resource *json_res; |
729 | json_t *name_json; | 724 | json_t *name_json; |
730 | json_t *records_json; | 725 | json_t *records_json; |
731 | char term_data[handle->data_size+1]; | 726 | char term_data[handle->rest_handle->data_size+1]; |
732 | 727 | ||
733 | if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url)) | 728 | if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url)) |
734 | { | 729 | { |
@@ -737,13 +732,15 @@ namestore_create_cont (struct RestConnectionDataHandle *con, | |||
737 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 732 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
738 | return; | 733 | return; |
739 | } | 734 | } |
740 | if (0 >= handle->data_size) | 735 | if (0 >= handle->rest_handle->data_size) |
741 | { | 736 | { |
742 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 737 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
743 | return; | 738 | return; |
744 | } | 739 | } |
745 | term_data[handle->data_size] = '\0'; | 740 | term_data[handle->rest_handle->data_size] = '\0'; |
746 | memcpy (term_data, handle->data, handle->data_size); | 741 | memcpy (term_data, |
742 | handle->rest_handle->data, | ||
743 | handle->rest_handle->data_size); | ||
747 | GNUNET_assert (GNUNET_OK == GNUNET_JSONAPI_object_parse (term_data, | 744 | GNUNET_assert (GNUNET_OK == GNUNET_JSONAPI_object_parse (term_data, |
748 | &json_obj)); | 745 | &json_obj)); |
749 | if (NULL == json_obj) | 746 | if (NULL == json_obj) |
@@ -853,7 +850,7 @@ namestore_zkey_response (void *cls, | |||
853 | } | 850 | } |
854 | 851 | ||
855 | static void | 852 | static void |
856 | namestore_zkey_cont (struct RestConnectionDataHandle *con, | 853 | namestore_zkey_cont (struct GNUNET_REST_RequestHandle *con, |
857 | const char *url, | 854 | const char *url, |
858 | void *cls) | 855 | void *cls) |
859 | { | 856 | { |
@@ -865,7 +862,7 @@ namestore_zkey_cont (struct RestConnectionDataHandle *con, | |||
865 | strlen (GNUNET_REST_JSONAPI_NAMESTORE_ZKEY), | 862 | strlen (GNUNET_REST_JSONAPI_NAMESTORE_ZKEY), |
866 | &key); | 863 | &key); |
867 | if ( GNUNET_NO == | 864 | if ( GNUNET_NO == |
868 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 865 | GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle->url_param_map, |
869 | &key) ) | 866 | &key) ) |
870 | { | 867 | { |
871 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 868 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -873,7 +870,7 @@ namestore_zkey_cont (struct RestConnectionDataHandle *con, | |||
873 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 870 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
874 | return; | 871 | return; |
875 | } | 872 | } |
876 | handle->zkey_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 873 | handle->zkey_str = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
877 | &key); | 874 | &key); |
878 | if (GNUNET_OK != | 875 | if (GNUNET_OK != |
879 | GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->zkey_str, | 876 | GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->zkey_str, |
@@ -893,7 +890,7 @@ namestore_zkey_cont (struct RestConnectionDataHandle *con, | |||
893 | } | 890 | } |
894 | 891 | ||
895 | static void | 892 | static void |
896 | namestore_info_cont (struct RestConnectionDataHandle *con, | 893 | namestore_info_cont (struct GNUNET_REST_RequestHandle *con, |
897 | const char *url, | 894 | const char *url, |
898 | void *cls) | 895 | void *cls) |
899 | { | 896 | { |
@@ -920,7 +917,7 @@ get_name_from_url (const char* url) | |||
920 | * @param cls the RequestHandle | 917 | * @param cls the RequestHandle |
921 | */ | 918 | */ |
922 | static void | 919 | static void |
923 | options_cont (struct RestConnectionDataHandle *con_handle, | 920 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, |
924 | const char* url, | 921 | const char* url, |
925 | void *cls) | 922 | void *cls) |
926 | { | 923 | { |
@@ -950,7 +947,8 @@ testservice_task (void *cls, | |||
950 | int result) | 947 | int result) |
951 | { | 948 | { |
952 | struct RequestHandle *handle = cls; | 949 | struct RequestHandle *handle = cls; |
953 | static const struct GNUNET_REST_RestConnectionHandler handlers[] = { | 950 | struct GNUNET_REST_RequestHandlerError err; |
951 | static const struct GNUNET_REST_RequestHandler handlers[] = { | ||
954 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_NAMESTORE_ZKEY, &namestore_zkey_cont}, //reverse | 952 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_NAMESTORE_ZKEY, &namestore_zkey_cont}, //reverse |
955 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_NAMESTORE, &namestore_info_cont}, //list | 953 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_NAMESTORE, &namestore_info_cont}, //list |
956 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_NAMESTORE, &namestore_create_cont}, //create | 954 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_NAMESTORE, &namestore_create_cont}, //create |
@@ -976,8 +974,14 @@ testservice_task (void *cls, | |||
976 | return; | 974 | return; |
977 | } | 975 | } |
978 | 976 | ||
979 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, handlers, handle)) | 977 | if (GNUNET_OK != GNUNET_JSONAPI_handle_request (handle->rest_handle, |
978 | handlers, | ||
979 | &err, | ||
980 | handle)) | ||
981 | { | ||
982 | handle->response_code = err.error_code; | ||
980 | GNUNET_SCHEDULER_add_now (&do_error, (void*) handle); | 983 | GNUNET_SCHEDULER_add_now (&do_error, (void*) handle); |
984 | } | ||
981 | 985 | ||
982 | } | 986 | } |
983 | 987 | ||
@@ -1079,10 +1083,10 @@ testservice_id_task (void *cls, int result) | |||
1079 | strlen (GNUNET_REST_JSONAPI_NAMESTORE_EGO), | 1083 | strlen (GNUNET_REST_JSONAPI_NAMESTORE_EGO), |
1080 | &key); | 1084 | &key); |
1081 | if ( GNUNET_YES == | 1085 | if ( GNUNET_YES == |
1082 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 1086 | GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle->url_param_map, |
1083 | &key) ) | 1087 | &key) ) |
1084 | { | 1088 | { |
1085 | ego = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 1089 | ego = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
1086 | &key); | 1090 | &key); |
1087 | } | 1091 | } |
1088 | 1092 | ||
@@ -1091,10 +1095,10 @@ testservice_id_task (void *cls, int result) | |||
1091 | strlen (GNUNET_REST_JSONAPI_NAMESTORE_RECORD_TYPE), | 1095 | strlen (GNUNET_REST_JSONAPI_NAMESTORE_RECORD_TYPE), |
1092 | &key); | 1096 | &key); |
1093 | if ( GNUNET_YES == | 1097 | if ( GNUNET_YES == |
1094 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 1098 | GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle->url_param_map, |
1095 | &key) ) | 1099 | &key) ) |
1096 | { | 1100 | { |
1097 | type = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 1101 | type = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
1098 | &key); | 1102 | &key); |
1099 | 1103 | ||
1100 | handle->type = GNUNET_GNSRECORD_typename_to_number (type); | 1104 | handle->type = GNUNET_GNSRECORD_typename_to_number (type); |
@@ -1134,7 +1138,7 @@ testservice_id_task (void *cls, int result) | |||
1134 | * @return GNUNET_OK if request accepted | 1138 | * @return GNUNET_OK if request accepted |
1135 | */ | 1139 | */ |
1136 | static void | 1140 | static void |
1137 | rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | 1141 | rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, |
1138 | GNUNET_REST_ResultProcessor proc, | 1142 | GNUNET_REST_ResultProcessor proc, |
1139 | void *proc_cls) | 1143 | void *proc_cls) |
1140 | { | 1144 | { |
@@ -1143,10 +1147,8 @@ rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | |||
1143 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; | 1147 | handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; |
1144 | handle->proc_cls = proc_cls; | 1148 | handle->proc_cls = proc_cls; |
1145 | handle->proc = proc; | 1149 | handle->proc = proc; |
1146 | handle->conndata_handle = conndata_handle; | 1150 | handle->rest_handle = rest_handle; |
1147 | handle->data = conndata_handle->data; | 1151 | GNUNET_asprintf (&handle->url, "%s", rest_handle->url); |
1148 | handle->data_size = conndata_handle->data_size; | ||
1149 | GNUNET_asprintf (&handle->url, "%s", conndata_handle->url); | ||
1150 | if (handle->url[strlen (handle->url)-1] == '/') | 1152 | if (handle->url[strlen (handle->url)-1] == '/') |
1151 | handle->url[strlen (handle->url)-1] = '\0'; | 1153 | handle->url[strlen (handle->url)-1] = '\0'; |
1152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c index ffd65228a..92bef1094 100644 --- a/src/rest/gnunet-rest-server.c +++ b/src/rest/gnunet-rest-server.c | |||
@@ -129,7 +129,7 @@ struct MhdConnectionHandle | |||
129 | 129 | ||
130 | struct GNUNET_REST_Plugin *plugin; | 130 | struct GNUNET_REST_Plugin *plugin; |
131 | 131 | ||
132 | struct RestConnectionDataHandle *data_handle; | 132 | struct GNUNET_REST_RequestHandle *data_handle; |
133 | 133 | ||
134 | int status; | 134 | int status; |
135 | 135 | ||
@@ -217,7 +217,7 @@ url_iterator (void *cls, | |||
217 | const char *key, | 217 | const char *key, |
218 | const char *value) | 218 | const char *value) |
219 | { | 219 | { |
220 | struct RestConnectionDataHandle *handle = cls; | 220 | struct GNUNET_REST_RequestHandle *handle = cls; |
221 | struct GNUNET_HashCode hkey; | 221 | struct GNUNET_HashCode hkey; |
222 | char *val; | 222 | char *val; |
223 | 223 | ||
@@ -274,7 +274,7 @@ create_response (void *cls, | |||
274 | char *plugin_name; | 274 | char *plugin_name; |
275 | struct GNUNET_HashCode key; | 275 | struct GNUNET_HashCode key; |
276 | struct MhdConnectionHandle *con_handle; | 276 | struct MhdConnectionHandle *con_handle; |
277 | struct RestConnectionDataHandle *rest_conndata_handle; | 277 | struct GNUNET_REST_RequestHandle *rest_conndata_handle; |
278 | 278 | ||
279 | con_handle = *con_cls; | 279 | con_handle = *con_cls; |
280 | 280 | ||
@@ -311,7 +311,7 @@ create_response (void *cls, | |||
311 | } | 311 | } |
312 | if (GN_REST_STATE_INIT == con_handle->state) | 312 | if (GN_REST_STATE_INIT == con_handle->state) |
313 | { | 313 | { |
314 | rest_conndata_handle = GNUNET_new (struct RestConnectionDataHandle); | 314 | rest_conndata_handle = GNUNET_new (struct GNUNET_REST_RequestHandle); |
315 | rest_conndata_handle->method = meth; | 315 | rest_conndata_handle->method = meth; |
316 | rest_conndata_handle->url = url; | 316 | rest_conndata_handle->url = url; |
317 | rest_conndata_handle->data = upload_data; | 317 | rest_conndata_handle->data = upload_data; |
diff --git a/src/rest/rest.c b/src/rest/rest.c index a17955314..bf32c9849 100644 --- a/src/rest/rest.c +++ b/src/rest/rest.c | |||
@@ -75,8 +75,9 @@ GNUNET_REST_create_json_response (const char *data) | |||
75 | } | 75 | } |
76 | 76 | ||
77 | int | 77 | int |
78 | GNUNET_REST_handle_request (struct RestConnectionDataHandle *conn, | 78 | GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn, |
79 | const struct GNUNET_REST_RestConnectionHandler *handlers, | 79 | const struct GNUNET_REST_RequestHandler *handlers, |
80 | struct GNUNET_REST_RequestHandlerError *err, | ||
80 | void *cls) | 81 | void *cls) |
81 | { | 82 | { |
82 | int count; | 83 | int count; |
@@ -104,6 +105,7 @@ GNUNET_REST_handle_request (struct RestConnectionDataHandle *conn, | |||
104 | return GNUNET_YES; | 105 | return GNUNET_YES; |
105 | } | 106 | } |
106 | GNUNET_free (url); | 107 | GNUNET_free (url); |
108 | err->error_code = MHD_HTTP_BAD_REQUEST; | ||
107 | return GNUNET_NO; | 109 | return GNUNET_NO; |
108 | } | 110 | } |
109 | 111 | ||