http_request.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*************************************************************************/
  2. /* http_request.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef HTTP_REQUEST_H
  31. #define HTTP_REQUEST_H
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #include "stddef.h"
  36. typedef enum {
  37. XHR_READY_STATE_UNSENT = 0,
  38. XHR_READY_STATE_OPENED = 1,
  39. XHR_READY_STATE_HEADERS_RECEIVED = 2,
  40. XHR_READY_STATE_LOADING = 3,
  41. XHR_READY_STATE_DONE = 4,
  42. } godot_xhr_ready_state_t;
  43. extern int godot_xhr_new();
  44. extern void godot_xhr_reset(int p_xhr_id);
  45. extern bool godot_xhr_free(int p_xhr_id);
  46. extern int godot_xhr_open(int p_xhr_id, const char *p_method, const char *p_url, const char *p_user = NULL, const char *p_password = NULL);
  47. extern void godot_xhr_set_request_header(int p_xhr_id, const char *p_header, const char *p_value);
  48. extern void godot_xhr_send_null(int p_xhr_id);
  49. extern void godot_xhr_send_string(int p_xhr_id, const char *p_data);
  50. extern void godot_xhr_send_data(int p_xhr_id, const void *p_data, int p_len);
  51. extern void godot_xhr_abort(int p_xhr_id);
  52. /* this is an HTTPClient::ResponseCode, not ::Status */
  53. extern int godot_xhr_get_status(int p_xhr_id);
  54. extern godot_xhr_ready_state_t godot_xhr_get_ready_state(int p_xhr_id);
  55. extern int godot_xhr_get_response_headers_length(int p_xhr_id);
  56. extern void godot_xhr_get_response_headers(int p_xhr_id, char *r_dst, int p_len);
  57. extern int godot_xhr_get_response_length(int p_xhr_id);
  58. extern void godot_xhr_get_response(int p_xhr_id, void *r_dst, int p_len);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif /* HTTP_REQUEST_H */