Commit 15622e69 authored by Dan Fandrich's avatar Dan Fandrich Committed by Daniel Stenberg
Browse files

sws: Added writedelay HTTP server command

This delays between write operations, hopefully making it easier
to spot problems where libcurl doesn't flush the socket properly
before waiting for the next response.
parent 85005862
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -124,6 +124,7 @@ auth_required if this is set and a POST/PUT is made without auth, the
                server will NOT wait for the full request body to get sent
                server will NOT wait for the full request body to get sent
idle            do nothing after receiving the request, just "sit idle"
idle            do nothing after receiving the request, just "sit idle"
stream          continuously send data to the client, never-ending
stream          continuously send data to the client, never-ending
writedelay: [secs] delay this amount between reply packets
pipe: [num]     tell the server to expect this many HTTP requests before
pipe: [num]     tell the server to expect this many HTTP requests before
                sending back anything, to allow pipelining tests
                sending back anything, to allow pipelining tests
skip: [num]     instructs the server to ignore reading this many bytes from a PUT
skip: [num]     instructs the server to ignore reading this many bytes from a PUT
+10 −3
Original line number Original line Diff line number Diff line
@@ -13,9 +13,10 @@ Range
HTTP/1.1 416 Requested Range Not Satisfiable
HTTP/1.1 416 Requested Range Not Satisfiable
Date: Thu, 09 Sep 2010 14:49:00 GMT
Date: Thu, 09 Sep 2010 14:49:00 GMT
Accept-Ranges: bytes
Accept-Ranges: bytes
Content-Length: 6
Content-Length: 115


Error
This is a long error message that is large enough that the test server is
guaranteed to split it into two packets.
</data>
</data>


<data1>
<data1>
@@ -28,6 +29,10 @@ Content-Type: text/plain


partial body
partial body
</data1>
</data1>

<servercmd>
writedelay: 1
</servercmd>
</reply>
</reply>


# Client-side
# Client-side
@@ -49,8 +54,10 @@ HTTP with invalid range then another URL
HTTP/1.1 416 Requested Range Not Satisfiable
HTTP/1.1 416 Requested Range Not Satisfiable
Date: Thu, 09 Sep 2010 14:49:00 GMT
Date: Thu, 09 Sep 2010 14:49:00 GMT
Accept-Ranges: bytes
Accept-Ranges: bytes
Content-Length: 6
Content-Length: 115


This is a long error message that is large enough that the test server is
guaranteed to split it into two packets.
HTTP/1.1 206 Partial Content
HTTP/1.1 206 Partial Content
Date: Thu, 09 Sep 2010 14:49:01 GMT
Date: Thu, 09 Sep 2010 14:49:01 GMT
Accept-Ranges: bytes
Accept-Ranges: bytes
+11 −0
Original line number Original line Diff line number Diff line
@@ -105,6 +105,8 @@ struct httprequest {
  size_t cl;      /* Content-Length of the incoming request */
  size_t cl;      /* Content-Length of the incoming request */
  bool digest;    /* Authorization digest header found */
  bool digest;    /* Authorization digest header found */
  bool ntlm;      /* Authorization ntlm header found */
  bool ntlm;      /* Authorization ntlm header found */
  int writedelay; /* if non-zero, delay this number of seconds between
		      writes in the response */
  int pipe;       /* if non-zero, expect this many requests to do a "piped"
  int pipe;       /* if non-zero, expect this many requests to do a "piped"
                     request/response */
                     request/response */
  int skip;       /* if non-zero, the server is instructed to not read this
  int skip;       /* if non-zero, the server is instructed to not read this
@@ -435,6 +437,10 @@ static int ProcessRequest(struct httprequest *req)
            logmsg("instructed to skip this number of bytes %d", num);
            logmsg("instructed to skip this number of bytes %d", num);
            req->skip = num;
            req->skip = num;
          }
          }
          else if(1 == sscanf(cmd, "writedelay: %d", &num)) {
            logmsg("instructed to delay %d secs between packets", num);
            req->writedelay = num;
          }
          else {
          else {
            logmsg("funny instruction found: %s", cmd);
            logmsg("funny instruction found: %s", cmd);
          }
          }
@@ -745,6 +751,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
  req->ntlm = FALSE;
  req->ntlm = FALSE;
  req->pipe = 0;
  req->pipe = 0;
  req->skip = 0;
  req->skip = 0;
  req->writedelay = 0;
  req->rcmd = RCMD_NORMALREQ;
  req->rcmd = RCMD_NORMALREQ;
  req->prot_version = 0;
  req->prot_version = 0;
  req->pipelining = FALSE;
  req->pipelining = FALSE;
@@ -1015,6 +1022,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
    else {
    else {
      logmsg("Sent off %zd bytes", written);
      logmsg("Sent off %zd bytes", written);
    }
    }
    if (req->writedelay) {
      logmsg("Pausing %d seconds", req->writedelay);
      sleep(req->writedelay);
    }
    /* write to file as well */
    /* write to file as well */
    fwrite(buffer, 1, (size_t)written, dump);
    fwrite(buffer, 1, (size_t)written, dump);
    if(got_exit_signal)
    if(got_exit_signal)