mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 00:58:48 -05:00
sendf: move the verbose-check into Curl_debug
Saves us from having the same check done everywhere. Closes #6159
This commit is contained in:
parent
606d213766
commit
d70a5b5a0f
@ -156,7 +156,6 @@ static CURLcode sendf(curl_socket_t sockfd, struct connectdata *conn,
|
||||
if(result)
|
||||
break;
|
||||
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written);
|
||||
|
||||
if((size_t)bytes_written != write_len) {
|
||||
|
17
lib/http.c
17
lib/http.c
@ -1254,16 +1254,12 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
|
||||
size_t headlen = (size_t)amount>headersize ? headersize : (size_t)amount;
|
||||
size_t bodylen = amount - headlen;
|
||||
|
||||
if(data->set.verbose) {
|
||||
/* this data _may_ contain binary stuff */
|
||||
Curl_debug(data, CURLINFO_HEADER_OUT, ptr, headlen);
|
||||
if(bodylen) {
|
||||
/* there was body data sent beyond the initial header part, pass that
|
||||
on to the debug callback too */
|
||||
Curl_debug(data, CURLINFO_DATA_OUT,
|
||||
ptr + headlen, bodylen);
|
||||
}
|
||||
}
|
||||
if(bodylen)
|
||||
/* there was body data sent beyond the initial header part, pass that on
|
||||
to the debug callback too */
|
||||
Curl_debug(data, CURLINFO_DATA_OUT, ptr + headlen, bodylen);
|
||||
|
||||
/* 'amount' can never be a very large value here so typecasting it so a
|
||||
signed 31 bit value should not cause problems even if ssize_t is
|
||||
@ -3537,9 +3533,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
|
||||
k->keepon &= ~KEEP_RECV;
|
||||
}
|
||||
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN,
|
||||
str_start, headerlen);
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, str_start, headerlen);
|
||||
break; /* exit header line loop */
|
||||
}
|
||||
|
||||
@ -4031,7 +4025,6 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
|
||||
if(data->set.include_header)
|
||||
writetype |= CLIENTWRITE_BODY;
|
||||
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, headp,
|
||||
Curl_dyn_len(&data->state.headerb));
|
||||
|
||||
|
@ -1496,7 +1496,6 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
|
||||
break;
|
||||
len = lf + 1 - trailp;
|
||||
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, trailp, len);
|
||||
/* pass the trailers one by one to the callback */
|
||||
result = Curl_client_write(conn, CLIENTWRITE_HEADER, trailp, len);
|
||||
|
@ -410,7 +410,6 @@ static CURLcode CONNECT(struct connectdata *conn,
|
||||
return result;
|
||||
|
||||
/* output debug if that is requested */
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, linep, perline);
|
||||
|
||||
if(!data->set.suppress_connect_headers) {
|
||||
|
@ -99,7 +99,6 @@ static CURLcode ftpsend(struct connectdata *conn, const char *cmd)
|
||||
if(result)
|
||||
break;
|
||||
|
||||
if(conn->data->set.verbose)
|
||||
Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, (size_t)bytes_written);
|
||||
|
||||
if(bytes_written != (ssize_t)write_len) {
|
||||
@ -716,7 +715,7 @@ int Curl_sec_read_msg(struct connectdata *conn, char *buffer,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(conn->data->set.verbose) {
|
||||
{
|
||||
buf[decoded_len] = '\n';
|
||||
Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ static CURLcode mqtt_send(struct connectdata *conn,
|
||||
struct MQTT *mq = data->req.protop;
|
||||
ssize_t n;
|
||||
result = Curl_write(conn, sockfd, buf, len, &n);
|
||||
if(!result && data->set.verbose)
|
||||
if(!result)
|
||||
Curl_debug(data, CURLINFO_HEADER_OUT, buf, (size_t)n);
|
||||
if(len != (size_t)n) {
|
||||
size_t nsend = len - n;
|
||||
@ -185,7 +185,6 @@ static CURLcode mqtt_verify_connack(struct connectdata *conn)
|
||||
if(result)
|
||||
goto fail;
|
||||
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
|
||||
|
||||
/* fixme */
|
||||
@ -298,7 +297,6 @@ static CURLcode mqtt_verify_suback(struct connectdata *conn)
|
||||
if(result)
|
||||
goto fail;
|
||||
|
||||
if(conn->data->set.verbose)
|
||||
Curl_debug(conn->data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
|
||||
|
||||
/* fixme */
|
||||
@ -486,7 +484,6 @@ static CURLcode mqtt_read_publish(struct connectdata *conn,
|
||||
result = CURLE_PARTIAL_FILE;
|
||||
goto end;
|
||||
}
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_DATA_IN, (char *)pkt, (size_t)nread);
|
||||
|
||||
mq->npacket -= nread;
|
||||
@ -558,7 +555,6 @@ static CURLcode mqtt_doing(struct connectdata *conn, bool *done)
|
||||
result = Curl_read(conn, sockfd, (char *)&mq->firstbyte, 1, &nread);
|
||||
if(result)
|
||||
break;
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, (char *)&mq->firstbyte, 1);
|
||||
/* remember the first byte */
|
||||
mq->npacket = 0;
|
||||
@ -569,7 +565,6 @@ static CURLcode mqtt_doing(struct connectdata *conn, bool *done)
|
||||
result = Curl_read(conn, sockfd, (char *)&byte, 1, &nread);
|
||||
if(result)
|
||||
break;
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, (char *)&byte, 1);
|
||||
pkt[mq->npacket++] = byte;
|
||||
} while((byte & 0x80) && (mq->npacket < 4));
|
||||
|
@ -218,7 +218,6 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
|
||||
conn->data_prot = data_sec;
|
||||
#endif
|
||||
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_OUT, s, (size_t)bytes_written);
|
||||
|
||||
if(bytes_written != (ssize_t)write_len) {
|
||||
@ -364,7 +363,6 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
|
||||
#ifdef HAVE_GSSAPI
|
||||
if(!conn->sec_complete)
|
||||
#endif
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_HEADER_IN,
|
||||
pp->linestart_resp, (size_t)perline);
|
||||
|
||||
|
@ -277,11 +277,8 @@ void Curl_failf(struct Curl_easy *data, const char *fmt, ...)
|
||||
strcpy(data->set.errorbuffer, error);
|
||||
data->state.errorbuf = TRUE; /* wrote error string */
|
||||
}
|
||||
if(data->set.verbose) {
|
||||
error[len] = '\n';
|
||||
error[++len] = '\0';
|
||||
error[len++] = '\n';
|
||||
Curl_debug(data, CURLINFO_TEXT, error, len);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
@ -693,9 +690,10 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
|
||||
int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||
char *ptr, size_t size)
|
||||
{
|
||||
int rc = 0;
|
||||
if(data->set.verbose) {
|
||||
static const char s_infotype[CURLINFO_END][3] = {
|
||||
"* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
|
||||
int rc = 0;
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
char *buf = NULL;
|
||||
@ -760,5 +758,6 @@ int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
free(buf);
|
||||
#endif
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -1152,7 +1152,6 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
|
||||
|
||||
win_update_buffer_size(conn->writesockfd);
|
||||
|
||||
if(data->set.verbose)
|
||||
/* show the data before we change the pointer upload_fromhere */
|
||||
Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere,
|
||||
(size_t)bytes_written);
|
||||
|
@ -1432,12 +1432,9 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
data->req.bytecount += sshc->readdir_len + 1;
|
||||
|
||||
/* output debug output if that is requested */
|
||||
if(data->set.verbose) {
|
||||
Curl_debug(data, CURLINFO_DATA_OUT,
|
||||
(char *)sshc->readdir_filename,
|
||||
Curl_debug(data, CURLINFO_DATA_OUT, (char *)sshc->readdir_filename,
|
||||
sshc->readdir_len);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sshc->readdir_currLen = strlen(sshc->readdir_longentry);
|
||||
sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
|
||||
@ -1548,12 +1545,9 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
sshc->readdir_currLen);
|
||||
|
||||
if(!result) {
|
||||
|
||||
/* output debug output if that is requested */
|
||||
if(data->set.verbose) {
|
||||
Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
|
||||
sshc->readdir_currLen);
|
||||
}
|
||||
data->req.bytecount += sshc->readdir_currLen;
|
||||
}
|
||||
Curl_safefree(sshc->readdir_line);
|
||||
@ -2638,10 +2632,9 @@ static void sftp_quote(struct connectdata *conn)
|
||||
sshc->nextstate = SSH_NO_STATE;
|
||||
return;
|
||||
}
|
||||
if(data->set.verbose) {
|
||||
Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4);
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
|
||||
}
|
||||
|
||||
/* this sends an FTP-like "header" to the header callback so that the
|
||||
current directory can be read very similar to how it is read when
|
||||
using ordinary FTP. */
|
||||
|
@ -1343,10 +1343,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
sshc->nextstate = SSH_NO_STATE;
|
||||
break;
|
||||
}
|
||||
if(data->set.verbose) {
|
||||
Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4);
|
||||
Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
|
||||
}
|
||||
|
||||
/* this sends an FTP-like "header" to the header callback so that the
|
||||
current directory can be read very similar to how it is read when
|
||||
using ordinary FTP. */
|
||||
@ -2167,12 +2166,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
data->req.bytecount += readdir_len + 1;
|
||||
|
||||
/* output debug output if that is requested */
|
||||
if(data->set.verbose) {
|
||||
Curl_debug(data, CURLINFO_DATA_IN, sshc->readdir_filename,
|
||||
readdir_len);
|
||||
Curl_debug(data, CURLINFO_DATA_IN, (char *)"\n", 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = Curl_dyn_add(&sshc->readdir, sshc->readdir_longentry);
|
||||
|
||||
@ -2252,13 +2249,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
Curl_dyn_len(&sshc->readdir));
|
||||
|
||||
if(!result) {
|
||||
|
||||
/* output debug output if that is requested */
|
||||
if(data->set.verbose) {
|
||||
Curl_debug(data, CURLINFO_DATA_IN,
|
||||
Curl_dyn_ptr(&sshc->readdir),
|
||||
Curl_dyn_len(&sshc->readdir));
|
||||
}
|
||||
data->req.bytecount += Curl_dyn_len(&sshc->readdir);
|
||||
}
|
||||
if(result) {
|
||||
@ -3037,7 +3031,6 @@ static ssize_t ssh_tls_recv(libssh2_socket_t sock, void *buffer,
|
||||
return -EAGAIN; /* magic return code for libssh2 */
|
||||
else if(result)
|
||||
return -1; /* generic error */
|
||||
if(conn->data->set.verbose)
|
||||
Curl_debug(conn->data, CURLINFO_DATA_IN, (char *)buffer, (size_t)nread);
|
||||
return nread;
|
||||
}
|
||||
@ -3061,7 +3054,6 @@ static ssize_t ssh_tls_send(libssh2_socket_t sock, const void *buffer,
|
||||
return -EAGAIN; /* magic return code for libssh2 */
|
||||
else if(result)
|
||||
return -1; /* error */
|
||||
if(conn->data->set.verbose)
|
||||
Curl_debug(conn->data, CURLINFO_DATA_OUT, (char *)buffer, (size_t)nwrite);
|
||||
return nwrite;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user