fork download
  1. HTTPC_STATUS_T http_get_large(const HTTPC_SESSION_T* session,
  2. const char* url,
  3. HTTP_GET_CALLBACK_T getWriteCallback) {
  4. ASSERT(session != NULL);
  5. ASSERT(session->handle != NULL);
  6.  
  7. wiced_result_t http_return;
  8. session_info * sinfo = (session_info *)(session->handle);
  9. HTTPC_STATUS_T return_value = HTTPC_ERROR;
  10.  
  11. if (sinfo->hnd.is_connected == 0) {
  12. http_return = open_session(&sinfo->hnd , url);
  13. }
  14.  
  15. http_return = http_stream_start_headers(&sinfo->hnd, HTTP_GET, url);
  16. if (http_return == WICED_SUCCESS) {
  17. if (sinfo->username_and_password != NULL) {
  18. http_return = http_send_basic_authorization(&sinfo->hnd,
  19. sinfo->username_and_password);
  20. if (http_return == WICED_SUCCESS) {
  21. if ((sinfo->stg.req_hdr_stg.name != NULL) &&
  22. (sinfo->stg.req_hdr_stg.value != NULL)) {
  23. http_header_t header = {
  24. .name = sinfo->stg.req_hdr_stg.name,
  25. .value = sinfo->stg.req_hdr_stg.value,
  26. };
  27.  
  28. http_return = http_stream_add_headers(&sinfo->hnd, &header, 1);
  29. if (http_return != WICED_SUCCESS) {
  30. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  31. "http_stream_add_headers failed. http_return = %d.\n",
  32. url, http_return);
  33. }
  34. }
  35. } else {
  36. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  37. "http_send_basic_authorization failed. http_return = %d.\n",
  38. url, http_return);
  39. }
  40. }
  41. } else {
  42. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  43. "http_stream_start_headers failed. http_return = %d.\n",
  44. url, http_return);
  45. }
  46. if (http_return == WICED_SUCCESS) {
  47. http_return = http_stream_end_headers(&sinfo->hnd, WICED_TRUE);
  48. if (http_return == WICED_SUCCESS) {
  49. http_return = http_stream_flush(&sinfo->hnd);
  50. if (http_return == WICED_SUCCESS) {
  51. wiced_packet_t *packet;
  52. http_return = http_stream_receive(&sinfo->hnd, &packet, sinfo->session_timeout *
  53. MS_PER_SECOND);
  54. if (http_return == WICED_SUCCESS) {
  55. http_status_code_t response_code;
  56. http_return = http_process_response(packet, &response_code);
  57. if (http_return == WICED_SUCCESS) {
  58. sinfo->result_code = response_code;
  59. if (response_code >= 200 && response_code < 302) {
  60. if (sinfo->result_code != HTTP_NO_CONTENT) {
  61. if ((getWriteCallback != NULL)) {
  62. do {
  63. unsigned char *buffer;
  64. uint32_t size;
  65. http_return = http_get_body(packet,
  66. &buffer,
  67. &size);
  68. if (http_return == WICED_SUCCESS) {
  69. if (size > 0)
  70. if ((getWriteCallback(buffer,
  71. http_return,
  72. NULL)) == 0) {
  73. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  74. "getWriteCallback() returned error.\n");
  75. break;
  76. }
  77. } else {
  78. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  79. "http_get_body failed. url = %s, http_return = %d.\n",
  80. url, http_return);
  81. }
  82. } while (http_return > 0);
  83. //FIXME: Add checking of failed callback
  84. if (http_return == WICED_SUCCESS) {
  85. return_value = HTTPC_SUCCESS;
  86. }
  87. } else {
  88. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  89. "http_get_large: getWriteCallback() is NULL.\n");
  90. }
  91. }
  92. } else {
  93. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  94. "http request failed. url = %s, status_code = %d.\n",
  95. url, sinfo->result_code);
  96. }
  97. } else {
  98. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  99. "http_process_response failed. url = %s, http_return = %d.\n",
  100. url, http_return);
  101. }
  102. } else {
  103. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  104. "http_stream_receive failed. url = %s, http_return = %d.\n",
  105. url, http_return);
  106. }
  107. } else {
  108. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  109. "http_stream_flush failed. url = %s, http_return = %d.\n",
  110. url, http_return);
  111. }
  112. } else {
  113. DEBUG_LOG(LOG_LEVEL_DEBUG, __FUNCTION__,
  114. "http_stream_end_headers failed. http_return = %d.\n",
  115. url, http_return);
  116. }
  117. }
  118.  
  119. return return_value;
  120. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:1: error: unknown type name 'HTTPC_STATUS_T'
 HTTPC_STATUS_T http_get_large(const HTTPC_SESSION_T* session,
 ^
prog.c:1:37: error: unknown type name 'HTTPC_SESSION_T'
 HTTPC_STATUS_T http_get_large(const HTTPC_SESSION_T* session,
                                     ^
prog.c:3:40: error: unknown type name 'HTTP_GET_CALLBACK_T'
                                        HTTP_GET_CALLBACK_T getWriteCallback) {
                                        ^
stdout
Standard output is empty