thget: use absolute url for POST through a proxy - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 598020ec4ebadc3351e698bc5b3005b315e97ff6
 (DIR) parent 0efbfd36f554a534750bbebb1e68a76aada3faa6
 (HTM) Author: Anthony Martin <ality@pbrane.org>
       Date:   Mon, 28 Jun 2010 14:37:26 -0700
       
       hget: use absolute url for POST through a proxy
       
       R=rsc
       CC=codebot
       http://codereview.appspot.com/1282042
       
       Diffstat:
         M src/cmd/hget.c                      |      24 +++++++++++++++++-------
       
       1 file changed, 17 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/hget.c b/src/cmd/hget.c
       t@@ -387,13 +387,23 @@ dohttp(URL *u, URL *px, Range *r, Out *out, long mtime)
                                        dfprint(fd,        "Authorization: Basic %s\r\n",
                                                        u->cred);
                        } else {
       -                        dfprint(fd,        "POST %s HTTP/1.0\r\n"
       -                                        "Host: %s\r\n"
       -                                        "Content-type: application/x-www-form-urlencoded\r\n"
       -                                        "Content-length: %d\r\n"
       -                                        "User-agent: Plan9/hget\r\n"
       -                                        "\r\n",
       -                                        u->page, u->host, strlen(u->postbody));
       +                        if(px->host == nil){
       +                                dfprint(fd,        "POST %s HTTP/1.0\r\n"
       +                                                "Host: %s\r\n"
       +                                                "Content-type: application/x-www-form-urlencoded\r\n"
       +                                                "Content-length: %d\r\n"
       +                                                "User-agent: Plan9/hget\r\n"
       +                                                "\r\n",
       +                                                u->page, u->host, strlen(u->postbody));
       +                        } else {
       +                                dfprint(fd, "POST http://%s%s HTTP/1.0\r\n"
       +                                                "Host: %s\r\n"
       +                                                "Content-type: application/x-www-form-urlencoded\r\n"
       +                                                "Content-length: %d\r\n"
       +                                                "User-agent: Plan9/hget\r\n"
       +                                                "\r\n",
       +                                                u->host, u->page, u->host, strlen(u->postbody));
       +                        }
                                dfprint(fd,        "%s", u->postbody);
                        }
                        if(r->start != 0){