* If flush_received is true, do not attempt to read any more; just use what's * in rpc->buf. */
| 911 | * in rpc->buf. |
| 912 | */ |
| 913 | static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_received) |
| 914 | { |
| 915 | struct active_request_slot *slot; |
| 916 | struct curl_slist *headers = NULL; |
| 917 | int use_gzip = rpc->gzip_request; |
| 918 | char *gzip_body = NULL; |
| 919 | size_t gzip_size = 0; |
| 920 | int err, large_request = 0; |
| 921 | int needs_100_continue = 0; |
| 922 | struct rpc_in_data rpc_in_data; |
| 923 | |
| 924 | /* Try to load the entire request, if we can fit it into the |
| 925 | * allocated buffer space we can use HTTP/1.0 and avoid the |
| 926 | * chunked encoding mess. |
| 927 | */ |
| 928 | if (!flush_received) { |
| 929 | while (1) { |
| 930 | size_t n; |
| 931 | enum packet_read_status status; |
| 932 | |
| 933 | if (!rpc_read_from_out(rpc, 0, &n, &status)) { |
| 934 | large_request = 1; |
| 935 | use_gzip = 0; |
| 936 | break; |
| 937 | } |
| 938 | if (status == PACKET_READ_FLUSH) |
| 939 | break; |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | if (large_request) { |
| 944 | struct slot_results results; |
| 945 | |
| 946 | do { |
| 947 | err = probe_rpc(rpc, &results); |
| 948 | if (err == HTTP_REAUTH) |
| 949 | http_reauth_prepare(0); |
| 950 | } while (err == HTTP_REAUTH); |
| 951 | if (err != HTTP_OK) |
| 952 | return -1; |
| 953 | |
| 954 | if (results.auth_avail & CURLAUTH_GSSNEGOTIATE || http_auth.authtype) |
| 955 | needs_100_continue = 1; |
| 956 | } |
| 957 | |
| 958 | retry: |
| 959 | headers = http_copy_default_headers(); |
| 960 | headers = curl_slist_append(headers, rpc->hdr_content_type); |
| 961 | headers = curl_slist_append(headers, rpc->hdr_accept); |
| 962 | headers = curl_slist_append(headers, needs_100_continue ? |
| 963 | "Expect: 100-continue" : "Expect:"); |
| 964 | |
| 965 | headers = http_append_auth_header(&http_auth, headers); |
| 966 | |
| 967 | /* Add Accept-Language header */ |
| 968 | if (rpc->hdr_accept_language) |
| 969 | headers = curl_slist_append(headers, rpc->hdr_accept_language); |
| 970 |
no test coverage detected