static const char s_infotype[CURLINFO_END][3] = {
"* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
if(data->set.fdebug) {
+ bool inCallback = Curl_is_in_callback(data);
Curl_set_in_callback(data, true);
(void)(*data->set.fdebug)(data, type, ptr, size, data->set.debugdata);
- Curl_set_in_callback(data, false);
+ Curl_set_in_callback(data, inCallback);
}
else {
switch(type) {
else if(nitems) {
unsigned char *frame = NULL;
size_t flen = 0;
+ size_t wrote = 0;
CURLcode result;
unsigned char *endp;
curl_off_t oleft;
}
else {
/* deliver the decoded frame to the user callback */
- if(data->set.fwrite_func((char *)frame, 1, flen, writebody_ptr) != flen)
+ Curl_set_in_callback(data, true);
+ wrote = data->set.fwrite_func((char *)frame, 1, flen, writebody_ptr);
+ Curl_set_in_callback(data, false);
+ if(wrote != flen)
return 0;
}
if(oleft)
out = data->state.ulbuf;
if(buflen)
/* for PING and PONG etc there might not be a payload */
- ws_xor(data, buffer, (unsigned char *)out + headlen, buflen - headlen);
- if(Curl_is_in_callback(data))
+ ws_xor(data, buffer, (unsigned char *)out + headlen, buflen);
+
+ if(data->set.connect_only)
+ result = Curl_senddata(data, out, buflen + headlen, &written);
+ else
result = Curl_write(data, data->conn->writesockfd, out,
buflen + headlen, &written);
- else
- result = Curl_senddata(data, out, buflen + headlen, &written);
infof(data, "WS: wanted to send %zu bytes, sent %zu bytes",
headlen + buflen, written);