]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
http: Record the last redirection type
authorKevin Cernekee <cernekee@gmail.com>
Sun, 28 Oct 2012 04:14:07 +0000 (21:14 -0700)
committerKevin Cernekee <cernekee@gmail.com>
Sun, 28 Oct 2012 08:22:56 +0000 (01:22 -0700)
The AnyConnect client uses the redirection type (new host, or just a
new URL on the same host) to figure out whether to use XML POST or
the old urlencoded scheme.  Preserve this information for future use.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
http.c
openconnect-internal.h

diff --git a/http.c b/http.c
index def8b9ddfe889cb8b3c1cbd8ff6169ca0dd24499..50816b8e8e147d3b04481688b20207261fbcad65 100644 (file)
--- a/http.c
+++ b/http.c
@@ -706,6 +706,8 @@ static void clear_cookies(struct openconnect_info *vpninfo)
  */
 static int handle_redirect(struct openconnect_info *vpninfo)
 {
+       vpninfo->redirect_type = REDIR_TYPE_LOCAL;
+
        if (!strncmp(vpninfo->redirect_url, "https://", 8)) {
                /* New host. Tear down the existing connection and make a new one */
                char *host;
@@ -735,6 +737,7 @@ static int handle_redirect(struct openconnect_info *vpninfo)
                        vpninfo->peer_addr = NULL;
                        openconnect_close_https(vpninfo, 0);
                        clear_cookies(vpninfo);
+                       vpninfo->redirect_type = REDIR_TYPE_NEWHOST;
                } else
                        free(host);
 
@@ -805,6 +808,8 @@ static int do_https_request(struct openconnect_info *vpninfo, const char *method
        int result, buflen;
 
  retry:
+       vpninfo->redirect_type = REDIR_TYPE_NONE;
+
        if (*form_buf) {
                free(*form_buf);
                *form_buf = NULL;
index f1a3fb63926d3da12e0c6f5ffd07ad4b11b91f8e..4b4c4550b1704217f54d518dd15f349e37e3bf01 100644 (file)
@@ -129,8 +129,13 @@ struct pin_cache {
 #define CERT_TYPE_PKCS12       2
 #define CERT_TYPE_TPM          3
 
+#define REDIR_TYPE_NONE                0
+#define REDIR_TYPE_NEWHOST     1
+#define REDIR_TYPE_LOCAL       2
+
 struct openconnect_info {
        char *redirect_url;
+       int redirect_type;
 
        const char *csd_xmltag;
        const char *platname;