sendf.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef HEADER_CURL_SENDF_H
  2. #define HEADER_CURL_SENDF_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #include "curl_setup.h"
  27. #include "curl_trc.h"
  28. /**
  29. * Type of data that is being written to the client (application)
  30. * - data written can be either BODY or META data
  31. * - META data is either INFO or HEADER
  32. * - INFO is meta information, e.g. not BODY, that cannot be interpreted
  33. * as headers of a response. Example FTP/IMAP pingpong answers.
  34. * - HEADER can have additional bits set (more than one)
  35. * - STATUS special "header", e.g. response status line in HTTP
  36. * - CONNECT header was received during proxying the connection
  37. * - 1XX header is part of an intermediate response, e.g. HTTP 1xx code
  38. * - TRAILER header is trailing response data, e.g. HTTP trailers
  39. * BODY, INFO and HEADER should not be mixed, as this would lead to
  40. * confusion on how to interpret/format/convert the data.
  41. */
  42. #define CLIENTWRITE_BODY (1<<0) /* non-meta information, BODY */
  43. #define CLIENTWRITE_INFO (1<<1) /* meta information, not a HEADER */
  44. #define CLIENTWRITE_HEADER (1<<2) /* meta information, HEADER */
  45. #define CLIENTWRITE_STATUS (1<<3) /* a special status HEADER */
  46. #define CLIENTWRITE_CONNECT (1<<4) /* a CONNECT related HEADER */
  47. #define CLIENTWRITE_1XX (1<<5) /* a 1xx response related HEADER */
  48. #define CLIENTWRITE_TRAILER (1<<6) /* a trailer HEADER */
  49. CURLcode Curl_client_write(struct Curl_easy *data, int type, char *ptr,
  50. size_t len) WARN_UNUSED_RESULT;
  51. CURLcode Curl_client_unpause(struct Curl_easy *data);
  52. void Curl_client_cleanup(struct Curl_easy *data);
  53. struct contenc_writer {
  54. const struct content_encoding *handler; /* Encoding handler. */
  55. struct contenc_writer *downstream; /* Downstream writer. */
  56. unsigned int order; /* Ordering within writer stack. */
  57. };
  58. /* Content encoding writer. */
  59. struct content_encoding {
  60. const char *name; /* Encoding name. */
  61. const char *alias; /* Encoding name alias. */
  62. CURLcode (*init_writer)(struct Curl_easy *data,
  63. struct contenc_writer *writer);
  64. CURLcode (*unencode_write)(struct Curl_easy *data,
  65. struct contenc_writer *writer,
  66. const char *buf, size_t nbytes);
  67. void (*close_writer)(struct Curl_easy *data,
  68. struct contenc_writer *writer);
  69. size_t writersize;
  70. };
  71. CURLcode Curl_client_create_writer(struct contenc_writer **pwriter,
  72. struct Curl_easy *data,
  73. const struct content_encoding *ce_handler,
  74. int order);
  75. void Curl_client_free_writer(struct Curl_easy *data,
  76. struct contenc_writer *writer);
  77. CURLcode Curl_client_add_writer(struct Curl_easy *data,
  78. struct contenc_writer *writer);
  79. /* internal read-function, does plain socket, SSL and krb4 */
  80. CURLcode Curl_read(struct Curl_easy *data, curl_socket_t sockfd,
  81. char *buf, size_t buffersize,
  82. ssize_t *n);
  83. /* internal write-function, does plain socket, SSL, SCP, SFTP and krb4 */
  84. CURLcode Curl_write(struct Curl_easy *data,
  85. curl_socket_t sockfd,
  86. const void *mem, size_t len,
  87. ssize_t *written);
  88. /* internal write-function, using sockindex for connection destination */
  89. CURLcode Curl_nwrite(struct Curl_easy *data,
  90. int sockindex,
  91. const void *buf,
  92. size_t blen,
  93. ssize_t *pnwritten);
  94. #endif /* HEADER_CURL_SENDF_H */