]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Loop until binding to the address
authorAnt Zucaro <azucaro@gmail.com>
Tue, 19 Feb 2013 22:26:22 +0000 (17:26 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Tue, 19 Feb 2013 22:26:22 +0000 (17:26 -0500)
xonstat/util/xs_interceptor/xs_interceptor.go

index 88eda745149e13aba8ffc9a4d9865f9eef53d979..abffb8709089b6bd8cc7a8423cee6a7dfa897244 100644 (file)
@@ -7,6 +7,7 @@ import "html/template"
 import "net/http"\r
 import "os"\r
 import "strings"\r
+import "time"\r
 import _ "github.com/mattn/go-sqlite3"\r
 \r
 // HTML templates\r
@@ -115,7 +116,13 @@ func serve(port int) {
        // serving\r
        fmt.Printf("Serving on port %d...\n", port)\r
        addr := fmt.Sprintf(":%d", port)\r
-       http.ListenAndServe(addr, nil)\r
+  for true {\r
+    err := http.ListenAndServe(addr, nil)\r
+    if err == nil {\r
+      fmt.Println("got it!")\r
+    }\r
+    time.Sleep(100*time.Millisecond)\r
+  }\r
 }\r
 \r
 // intercepts all URLs, displays a landing page\r
@@ -211,7 +218,9 @@ func resubmit(url string) {
                }\r
 \r
                req, _ := http.NewRequest("POST", url, strings.NewReader(body))\r
-               req.ContentLength = int64(bodylength)\r
+               //req.ContentLength = int64(bodylength)\r
+    //req.ContentLength = 0\r
+               req.ContentLength = int64(len([]byte(body)))\r
 \r
                header := map[string][]string{\r
                        "X-D0-Blind-Id-Detached-Signature": {blind_id_header},\r
@@ -222,6 +231,7 @@ func resubmit(url string) {
                res, err := http.DefaultClient.Do(req)\r
                if err != nil {\r
                        fmt.Printf("Error submitting request #%d. Continuing...\n", request_id)\r
+                       fmt.Println(err)\r
                        continue\r
                }\r
                defer res.Body.Close()\r