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, <daniel@haxx.se>, 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 27 #include "curl_setup.h" 28 29 #include "curl_trc.h" 30 31 /** 32 * Type of data that is being written to the client (application) 33 * - data written can be either BODY or META data 34 * - META data is either INFO or HEADER 35 * - INFO is meta information, e.g. not BODY, that cannot be interpreted 36 * as headers of a response. Example FTP/IMAP pingpong answers. 37 * - HEADER can have additional bits set (more than one) 38 * - STATUS special "header", e.g. response status line in HTTP 39 * - CONNECT header was received during proxying the connection 40 * - 1XX header is part of an intermediate response, e.g. HTTP 1xx code 41 * - TRAILER header is trailing response data, e.g. HTTP trailers 42 * BODY, INFO and HEADER should not be mixed, as this would lead to 43 * confusion on how to interpret/format/convert the data. 44 */ 45 #define CLIENTWRITE_BODY (1<<0) /* non-meta information, BODY */ 46 #define CLIENTWRITE_INFO (1<<1) /* meta information, not a HEADER */ 47 #define CLIENTWRITE_HEADER (1<<2) /* meta information, HEADER */ 48 #define CLIENTWRITE_STATUS (1<<3) /* a special status HEADER */ 49 #define CLIENTWRITE_CONNECT (1<<4) /* a CONNECT related HEADER */ 50 #define CLIENTWRITE_1XX (1<<5) /* a 1xx response related HEADER */ 51 #define CLIENTWRITE_TRAILER (1<<6) /* a trailer HEADER */ 52 53 CURLcode Curl_client_write(struct Curl_easy *data, int type, char *ptr, 54 size_t len) WARN_UNUSED_RESULT; 55 56 CURLcode Curl_client_unpause(struct Curl_easy *data); 57 void Curl_client_cleanup(struct Curl_easy *data); 58 59 struct contenc_writer { 60 const struct content_encoding *handler; /* Encoding handler. */ 61 struct contenc_writer *downstream; /* Downstream writer. */ 62 unsigned int order; /* Ordering within writer stack. */ 63 }; 64 65 /* Content encoding writer. */ 66 struct content_encoding { 67 const char *name; /* Encoding name. */ 68 const char *alias; /* Encoding name alias. */ 69 CURLcode (*init_writer)(struct Curl_easy *data, 70 struct contenc_writer *writer); 71 CURLcode (*unencode_write)(struct Curl_easy *data, 72 struct contenc_writer *writer, 73 const char *buf, size_t nbytes); 74 void (*close_writer)(struct Curl_easy *data, 75 struct contenc_writer *writer); 76 size_t writersize; 77 }; 78 79 80 CURLcode Curl_client_create_writer(struct contenc_writer **pwriter, 81 struct Curl_easy *data, 82 const struct content_encoding *ce_handler, 83 int order); 84 85 void Curl_client_free_writer(struct Curl_easy *data, 86 struct contenc_writer *writer); 87 88 CURLcode Curl_client_add_writer(struct Curl_easy *data, 89 struct contenc_writer *writer); 90 91 92 /* internal read-function, does plain socket, SSL and krb4 */ 93 CURLcode Curl_read(struct Curl_easy *data, curl_socket_t sockfd, 94 char *buf, size_t buffersize, 95 ssize_t *n); 96 97 /* internal write-function, does plain socket, SSL, SCP, SFTP and krb4 */ 98 CURLcode Curl_write(struct Curl_easy *data, 99 curl_socket_t sockfd, 100 const void *mem, size_t len, 101 ssize_t *written); 102 103 /* internal write-function, using sockindex for connection destination */ 104 CURLcode Curl_nwrite(struct Curl_easy *data, 105 int sockindex, 106 const void *buf, 107 size_t blen, 108 ssize_t *pnwritten); 109 110 #endif /* HEADER_CURL_SENDF_H */ 111