Last active
November 5, 2019 15:54
-
-
Save wjiec/4f76bb61e29d327fead958cde0f6f1b0 to your computer and use it in GitHub Desktop.
Revisions
-
wjiec revised this gist
Nov 5, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ package main import ( "log" "net/http" "strings" -
wjiec revised this gist
Oct 16, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import ( func main() { http.HandleFunc("/", func(w http.ResponseWriter, request *http.Request) { userAgent := request.Header.Get("user-agent") if strings.Contains(userAgent, "MicroMessenger") && strings.Contains(userAgent, "Android") { w.Header().Add("Content-Disposition", "attachment; filename=1.apk") w.Header().Add("Content-Type", "text/plain; charset=utf-8") -
wjiec created this gist
Oct 16, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ package main import ( "fmt" "log" "net/http" "strings" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, request *http.Request) { userAgent := request.Header.Get("user-agent") fmt.Println(userAgent) if strings.Contains(userAgent, "MicroMessenger") && strings.Contains(userAgent, "Android") { w.Header().Add("Content-Disposition", "attachment; filename=1.apk") w.Header().Add("Content-Type", "text/plain; charset=utf-8") w.WriteHeader(http.StatusPartialContent) return } _, _ = w.Write([]byte("hello")) }) log.Fatal(http.ListenAndServe(":8898", nil)) }