-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP(x/http/client): Implement http.Post() and redirection logic
- Loading branch information
Showing
17 changed files
with
1,482 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
github.com/goplus/llgo v0.9.7-0.20240812013847-321766fd4641 h1:VIJ38bCFRIIr62YXyRKkxy6GXYVA6R3xqAb0HkcoUgw= | ||
github.com/goplus/llgo v0.9.7-0.20240812013847-321766fd4641/go.mod h1:5Fs+08NslqofJ7xtOiIXugkurYOoQvY02ZkFNWA1uEI= | ||
github.com/goplus/llgo v0.9.7-0.20240816085229-53d2d080f4c4 h1:fqqbWhWaoseSplLJF8OTkNGl4Kruqm1wQWT/Yooq6E4= | ||
github.com/goplus/llgo v0.9.7-0.20240816085229-53d2d080f4c4/go.mod h1:5Fs+08NslqofJ7xtOiIXugkurYOoQvY02ZkFNWA1uEI= | ||
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= | ||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= | ||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= | ||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/goplus/llgoexamples/x/http" | ||
) | ||
|
||
func main() { | ||
resp, err := http.Get("http://localhost:8080") // Start "../server/redirectServer.go" before running | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
fmt.Println(resp.Status, "read bytes: ", resp.ContentLength) | ||
fmt.Println(resp.Proto) | ||
resp.PrintHeaders() | ||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
fmt.Println(string(body)) | ||
defer resp.Body.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
func main() { | ||
http.HandleFunc("/", handleInitialRequest) | ||
http.HandleFunc("/redirect", handleRedirectRequest) | ||
|
||
fmt.Println("Server is running on http://localhost:8080") | ||
log.Fatal(http.ListenAndServe(":8080", nil)) | ||
} | ||
|
||
func handleInitialRequest(w http.ResponseWriter, r *http.Request) { | ||
log.Println("Received initial request, redirecting...") | ||
http.Redirect(w, r, "/redirect", http.StatusSeeOther) | ||
} | ||
|
||
func handleRedirectRequest(w http.ResponseWriter, r *http.Request) { | ||
log.Println("Received redirect request, sending response...") | ||
w.WriteHeader(http.StatusOK) | ||
fmt.Fprint(w, "Hello redirect") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.