Commit 3a61c98b authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Peter Sylvester brought code that now allows a callback to modified the URL

even when the multi interface is used, and then libcurl will simulate a
"follow location" to that new URL. Test 509 was added to test this feature.
parent 5173bab0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -7,6 +7,10 @@
                                  Changelog

Daniel (12 January 2004)
- Peter Sylvester brought code that now allows a callback to modified the URL
  even when the multi interface is used, and then libcurl will simulate a
  "follow location" to that new URL. Test 509 was added to test this feature.

- Extended the time we retry servers in the test script, and I also made it
  retry the https and ftps servers before they are considered bad. I believe
  the previous approach could turn problematic on really slow hosts.
+169 −149
Original line number Diff line number Diff line
@@ -320,11 +320,27 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)

  easy=multi->easy.next;
  while(easy) {

#ifdef CURLDEBUG
    fprintf(stderr, "HANDLE %p: State: %x\n",
            (char *)easy, easy->state);
#endif
    do {
      if (CURLM_STATE_WAITCONNECT <= easy->state &&
          easy->state <= CURLM_STATE_DO &&
          easy->easy_handle->change.url_changed) {
        char *gotourl;
        Curl_posttransfer(easy->easy_handle);

        gotourl = strdup(easy->easy_handle->change.url);
        easy->easy_handle->change.url_changed = FALSE;
        easy->result = Curl_follow(easy->easy_handle, gotourl);
        if(CURLE_OK == easy->result)
          easy->state = CURLM_STATE_CONNECT;
        else
          free(gotourl);
      }
    
      easy->easy_handle->change.url_changed = FALSE;

      switch(easy->state) {
      case CURLM_STATE_INIT:
@@ -343,7 +359,8 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
      case CURLM_STATE_CONNECT:
        /* Connect. We get a connection identifier filled in. */
        Curl_pgrsTime(easy->easy_handle, TIMER_STARTSINGLE);
      easy->result = Curl_connect(easy->easy_handle, &easy->easy_conn, &async);
        easy->result = Curl_connect(easy->easy_handle, &easy->easy_conn,
                                    &async);

        if(CURLE_OK == easy->result) {
          if(async)
@@ -436,7 +453,8 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
        /*
         * First, check if we really are ready to do more.
         */
      easy->result = Curl_is_connected(easy->easy_conn,
        easy->result =
          Curl_is_connected(easy->easy_conn,
                            easy->easy_conn->sock[SECONDARYSOCKET],
                            &connected);
        if(connected) {
@@ -528,6 +546,8 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
          (*running_handles)++;
      }

    } while (easy->easy_handle->change.url_changed);

    if ((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) {
      /* clear out the usage of the shared DNS cache */
      easy->easy_handle->hostcache = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -24,4 +24,4 @@ test62 test63 test64 test65 test66 test144 test145 test67 test68 test41 \
test40 test42 test69 test70 test71 test72 test73 test146 test505 \
test74 test75 test76 test77 test78 test147 test148 test506 test79 test80 \
test81 test82 test83 test84 test85 test86 test87 test507 test149 test88 \
test89 test90 test508 test91 test92 test203 test93 test94 test95
test89 test90 test508 test91 test92 test203 test93 test94 test95 test509

tests/data/test509

0 → 100644
+51 −0
Original line number Diff line number Diff line
#
# Server-side
<reply>
<data>
HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: localhost:8433
Content-length:6

Hello
</data>
<datacheck>
Hello
</datacheck>
</reply>

#
# Client-side
<client>
<server>
https
</server>
<features>
SSL
</features>
<tool>
lib509
</tool>

 <name>
simple HTTPS GET and URL redirect in certificate
 </name>
 <command>
https://localhost:%HTTPSPORT/dvcs
</command>
</client>

#
# Verify data after the test has been "shot"
<verify>
<strip>
^User-Agent:.*
</strip>
<protocol>
GET /509 HTTP/1.1
Host: localhost:8433
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

</protocol>
</verify>
+5 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ SUPPORTFILES = first.c test.h

# here are all tools used for running libcurl tests
noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \
  lib508
  lib508 lib509

lib500_SOURCES = lib500.c $(SUPPORTFILES)
lib500_LDADD = $(LIBDIR)/libcurl.la
@@ -49,3 +49,7 @@ lib507_DEPENDENCIES = $(LIBDIR)/libcurl.la
lib508_SOURCES = lib508.c $(SUPPORTFILES)
lib508_LDADD = $(LIBDIR)/libcurl.la
lib508_DEPENDENCIES = $(LIBDIR)/libcurl.la

lib509_SOURCES = lib509.c $(SUPPORTFILES)
lib509_LDADD = $(LIBDIR)/libcurl.la
lib509_DEPENDENCIES = $(LIBDIR)/libcurl.la
Loading