Commit 22cfeac7 authored by Jay Satiro's avatar Jay Satiro
Browse files

easy: Reset all statistical session info in curl_easy_reset

Bug: https://github.com/curl/curl/issues/1017
Reported-by: Jeroen Ooms
parent 6834ebaa
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -995,6 +995,9 @@ void curl_easy_reset(struct Curl_easy *data)
  /* zero out Progress data: */
  memset(&data->progress, 0, sizeof(struct Progress));

  /* zero out PureInfo data: */
  Curl_initinfo(data);

  data->progress.flags |= PGRS_HIDE;
  data->state.current_speed = -1; /* init to negative == impossible */
}
+14 −5
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@
#include "memdebug.h"

/*
 * This is supposed to be called in the beginning of a perform() session
 * and should reset all session-info variables
 * This is supposed to be called in the beginning of a perform() session and
 * in curl_easy_reset() and should reset all session-info variables.
 */
CURLcode Curl_initinfo(struct Curl_easy *data)
{
@@ -58,18 +58,27 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
  info->filetime = -1; /* -1 is an illegal time and thus means unknown */
  info->timecond = FALSE;

  free(info->contenttype);
  info->contenttype = NULL;

  info->header_size = 0;
  info->request_size = 0;
  info->proxyauthavail = 0;
  info->httpauthavail = 0;
  info->numconnects = 0;

  free(info->contenttype);
  info->contenttype = NULL;

  free(info->wouldredirect);
  info->wouldredirect = NULL;

  info->conn_primary_ip[0] = '\0';
  info->conn_local_ip[0] = '\0';
  info->conn_primary_port = 0;
  info->conn_local_port = 0;

#ifdef USE_SSL
  Curl_ssl_free_certinfo(data);
#endif

  return CURLE_OK;
}

+1 −0
Original line number Diff line number Diff line
@@ -1104,6 +1104,7 @@ struct connectdata {

/*
 * Struct to keep statistical and informational data.
 * All variables in this struct must be reset in Curl_initinfo().
 */
struct PureInfo {
  int httpcode;  /* Recent HTTP, FTP, RTSP or SMTP response code */
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ test1516 test1517 \
\
test1520 \
\
test1525 test1526 test1527 test1528 test1529 test1530 test1531 \
test1525 test1526 test1527 test1528 test1529 test1530 test1531 test1532 \
\
test1600 test1601 test1602 test1603 test1604 test1605 \
\

tests/data/test1532

0 → 100644
+49 −0
Original line number Diff line number Diff line
<testcase>
<info>
<keywords>
HTTP
HTTP GET
</keywords>
</info>

#
# Server-side
<reply>
<data nocheck="yes">
HTTP/1.0 200 OK swsclose
Content-Length: 0

</data>
</reply>

# Client-side
<client>
<server>
http
</server>
# tool is what to use instead of 'curl'
<tool>
lib1532
</tool>
<name>
Test CURLINFO_RESPONSE_CODE
</name>
<command>
http://%HOSTIP:%HTTPPORT/1532
</command>
</client>

#
# Verify data after the test has been "shot"
<verify>
<protocol>
GET /1532 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*

</protocol>
<errorcode>
0
</errorcode>
</verify>
</testcase>
Loading