http: Fix memory leak in do_https_request()

Returning after a redirect can leak the oc_text_buf struct:

    ==5844== 4,120 (24 direct, 4,096 indirect) bytes in 1 blocks are definitely lost in loss record 47 of 50
    ==5844==    at 0x4C29DB4: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5844==    by 0x4E3CFDF: do_https_request (http.c:929)
    ==5844==    by 0x4E3D485: openconnect_obtain_cookie (http.c:1117)
    ==5844==    by 0x403135: main (main.c:1038)

So make sure we call buf_free() first.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
http: Call buf_truncate() before appending XML POST data

If the buffer isn't cleared, openconnect may send garbled requests.  For
instance, this is what happened when it tried to send a
<client-cert-fail/> response:

    > <?xml version="1.0" encoding="UTF-8"?>
    > <config-auth client="vpn" type="init"><version who="vpn">v6.00-27-gd6ce12e-dirty</version><device-id>win</device-id><group-access>https://asa</group-access></config-auth>
    > <?xml version="1.0" encoding="UTF-8"?>
    > <config-auth client="vpn" type="init"><version who="vpn">v6.00-27-gd6ce12e-dirty</version><device-id>win</device-id><group-access>https://asa</group-access><client-cert-fail/></config-auth>

    < <?xml version="1.0" encoding="UTF-8"?>
    < <config-auth client="vpn" type="complete">
    < <version who="sg">8.4(4)5</version>
    < <error id="98" param1="" param2="">VPN Server could not parse request.</error>
    < </config-auth>
    XML response has no "auth" node

...and then it fell back to non-xmlpost mode, a regression from v6.00.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
http: Don't leak orig_host or orig_path

Commit 35a59dd9f (Clean up return paths in openconnect_obtain_cookie())
moved the free()ing of these buffers to the end of the function.  But
they should also be freed on each "newgroup" loop iteration, or else this
happens:

    ==9457== 2 bytes in 2 blocks are definitely lost in loss record 1 of 50
    ==9457==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==9457==    by 0x565FD81: strdup (strdup.c:43)
    ==9457==    by 0x4E3D582: openconnect_obtain_cookie (http.c:1089)
    ==9457==    by 0x403135: main (main.c:1038)
    ==9457==
    ==9457== 12 bytes in 3 blocks are definitely lost in loss record 10 of 50
    ==9457==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==9457==    by 0x565FD81: strdup (strdup.c:43)
    ==9457==    by 0x4E3D56E: openconnect_obtain_cookie (http.c:1088)
    ==9457==    by 0x403135: main (main.c:1038)

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
http: Fix CSD https requests

If request_body is NULL, buf_error(request_body) will return -ENOMEM to
indicate an allocation failure.  This is a good thing if we just called
buf_alloc(), but it is a bad thing if we aren't actually passing in a
request_body pointer.

The CSD GET requests pass in a NULL request_body and request_body_type:

    result = do_https_request(vpninfo, "GET", NULL, NULL, &form_buf, 0);

so this change is needed to restore proper CSD operation.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>