From 139a6f80dc258bba1e61aa9584787b86ac4addf3 Mon Sep 17 00:00:00 2001 From: skyblue Date: Sun, 23 Mar 2014 23:22:35 +0800 Subject: [PATCH 01/11] update my config --- conf/app.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index ab9f6dc4bb5..b9472b551a4 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -2,7 +2,7 @@ APP_NAME = Gogs: Go Git Service APP_LOGO = img/favicon.png ; !!MUST CHANGE TO YOUR USER NAME!! -RUN_USER = lunny +RUN_USER = skyblue ; Either "dev", "prod" or "test", default is "dev" RUN_MODE = dev @@ -164,4 +164,4 @@ RECEIVERS = [log.database] LEVEL = Driver = -CONN = \ No newline at end of file +CONN = From 1d30f545d65fe2d7fe6e0a88fbb693ca68e9417e Mon Sep 17 00:00:00 2001 From: lunny Date: Mon, 24 Mar 2014 14:28:20 +0000 Subject: [PATCH 02/11] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..6cd1df2b7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..3af16b07244 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file From d24a4a142e5de9b2d9701ae93892234122e8b89b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 25 Mar 2014 17:11:13 +0800 Subject: [PATCH 03/11] bug fixed --- serve.go | 55 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/serve.go b/serve.go index c3eb233c76d..f9e915ed841 100644 --- a/serve.go +++ b/serve.go @@ -109,20 +109,25 @@ func runServ(k *cli.Context) { repoName = repoName[:len(repoName)-4] } + isWrite := In(verb, COMMANDS_WRITE) + isRead := In(verb, COMMANDS_READONLY) + repo, err := models.GetRepositoryByName(user.Id, repoName) var isExist bool = true if err != nil { if err == models.ErrRepoNotExist { isExist = false + if isRead { + println("Repository", user.Name+"/"+repoName, "is not exist") + return + } } else { - println("Unavilable repository", err) + println("Get repository error:", err) return } } - isWrite := In(verb, COMMANDS_WRITE) - isRead := In(verb, COMMANDS_READONLY) - + // access check switch { case isWrite: has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE) @@ -156,12 +161,11 @@ func runServ(k *cli.Context) { return } + var rep *git.Repository + repoPath := models.RepoPath(user.Name, repoName) if !isExist { - if isRead { - println("Repository", user.Name+"/"+repoName, "is not exist") - return - } else if isWrite { - _, err := models.CreateRepository(user, repoName, "", "", "", false, true) + if isWrite { + _, err = models.CreateRepository(user, repoName, "", "", "", false, true) if err != nil { println("Create repository failed") return @@ -169,11 +173,11 @@ func runServ(k *cli.Context) { } } - rep, err := git.OpenRepository(models.RepoPath(user.Name, repoName)) - if err != nil { - println(err.Error()) - return - } + rep, err = git.OpenRepository(repoPath) + if err != nil { + println(err.Error()) + return + } refs, err := rep.AllReferencesMap() if err != nil { @@ -194,17 +198,14 @@ func runServ(k *cli.Context) { if err = gitcmd.Run(); err != nil { println("execute command error:", err.Error()) + return } - if !strings.HasPrefix(cmd, "git-receive-pack") { + if isRead { return } - // update - //w, _ := os.Create("serve.log") - //defer w.Close() - //log.SetOutput(w) - + // find push reference name var t = "ok refs/heads/" var i int var refname string @@ -220,12 +221,17 @@ func runServ(k *cli.Context) { refname = l[idx+len(t):] } } + if refname == "" { + println("No find any reference name:", b.String()) + return + } + var ref *git.Reference var ok bool - var l *list.List //log.Info("----", refname, "-----") if ref, ok = refs[refname]; !ok { + // for new branch refs, err = rep.AllReferencesMap() if err != nil { println(err.Error()) @@ -280,13 +286,8 @@ func runServ(k *cli.Context) { repo.Id, repoName, refname, &base.PushCommits{l.Len(), commits}); err != nil { log.Error("runUpdate.models.CommitRepoAction: %v", err, commits) } else { - //log.Info("refname", refname) - //log.Info("Listen: %v", cmd) - //fmt.Println("...", cmd) - - //runUpdate(k) c := exec.Command("git", "update-server-info") - c.Dir = models.RepoPath(user.Name, repoName) + c.Dir = repoPath err := c.Run() if err != nil { log.Error("update-server-info: %v", err) From c61fa28f49f9bed8e198f0ef8b2b18afec921ae5 Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Tue, 25 Mar 2014 17:17:34 +0800 Subject: [PATCH 04/11] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..6cd1df2b7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..3af16b07244 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file From 649bc91057398e6c7cd31b41f15fafeffba167ef Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Tue, 25 Mar 2014 17:25:55 +0800 Subject: [PATCH 05/11] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..6cd1df2b7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..3af16b07244 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file From a80603727db5a6871a833310bb47431e97628109 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 25 Mar 2014 17:52:03 +0800 Subject: [PATCH 06/11] add log --- serve.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/serve.go b/serve.go index 480b122f3b3..8d9fd69cdab 100644 --- a/serve.go +++ b/serve.go @@ -48,6 +48,7 @@ gogs serv provide access auth for repositories`, func init() { os.MkdirAll("log", os.ModePerm) log.NewLogger(10000, "file", fmt.Sprintf(`{"filename":"%s"}`, "log/serv.log")) + log.Info("start logging...") } func parseCmd(cmd string) (string, string) { @@ -124,6 +125,7 @@ func runServ(k *cli.Context) { } } else { println("Get repository error:", err) + log.Error(err.Error()) return } } @@ -134,6 +136,7 @@ func runServ(k *cli.Context) { has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE) if err != nil { println("Inernel error:", err) + log.Error(err.Error()) return } if !has { @@ -144,12 +147,14 @@ func runServ(k *cli.Context) { has, err := models.HasAccess(user.Name, repoName, models.AU_READABLE) if err != nil { println("Inernel error") + log.Error(err.Error()) return } if !has { has, err = models.HasAccess(user.Name, repoName, models.AU_WRITABLE) if err != nil { println("Inernel error") + log.Error(err.Error()) return } } @@ -169,6 +174,7 @@ func runServ(k *cli.Context) { _, err = models.CreateRepository(user, repoName, "", "", "", false, true) if err != nil { println("Create repository failed") + log.Error(err.Error()) return } } @@ -177,12 +183,14 @@ func runServ(k *cli.Context) { rep, err = git.OpenRepository(repoPath) if err != nil { println(err.Error()) + log.Error(err.Error()) return } refs, err := rep.AllReferencesMap() if err != nil { println(err.Error()) + log.Error(err.Error()) return } @@ -199,6 +207,7 @@ func runServ(k *cli.Context) { if err = gitcmd.Run(); err != nil { println("execute command error:", err.Error()) + log.Error(err.Error()) return } @@ -238,15 +247,17 @@ func runServ(k *cli.Context) { refs, err = rep.AllReferencesMap() if err != nil { println(err.Error()) + log.Error(err.Error()) return } if ref, ok = refs[refname]; !ok { - log.Trace("unknow reference name -", refname, "-", b.String()) + log.Error("unknow reference name -", refname, "-", b.String()) return } l, err = ref.AllCommits() if err != nil { println(err.Error()) + log.Error(err.Error()) return } } else { @@ -256,12 +267,14 @@ func runServ(k *cli.Context) { last, err = ref.LastCommit() if err != nil { println(err.Error()) + log.Error(err.Error()) return } ref2, err := rep.LookupReference(ref.Name) if err != nil { println(err.Error()) + log.Error(err.Error()) return } @@ -269,6 +282,7 @@ func runServ(k *cli.Context) { before, err := ref2.LastCommit() if err != nil { println(err.Error()) + log.Error(err.Error()) return } //log.Info("----", before.Id(), "-----", last.Id()) From d8b859ec86560844fd230542e7958cd3912c0b1e Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Tue, 25 Mar 2014 17:53:03 +0800 Subject: [PATCH 07/11] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..6cd1df2b7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..3af16b07244 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file From 2856bee02201677f362dc587441970eeba219da2 Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Tue, 25 Mar 2014 18:12:51 +0800 Subject: [PATCH 08/11] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..6cd1df2b7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..3af16b07244 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file From 19b7f74b75caf8cef50c687d422d761ca74b3b90 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 25 Mar 2014 18:26:30 +0800 Subject: [PATCH 09/11] add log --- serve.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/serve.go b/serve.go index 6add5a9bd8b..acdcb877ffd 100644 --- a/serve.go +++ b/serve.go @@ -183,14 +183,14 @@ func runServ(k *cli.Context) { rep, err = git.OpenRepository(repoPath) if err != nil { - println(err.Error()) + println("OpenRepository failed:", err.Error()) log.Error(err.Error()) return } refs, err := rep.AllReferencesMap() if err != nil { - println(err.Error()) + println("Get All References failed:", err.Error()) log.Error(err.Error()) return } @@ -247,7 +247,7 @@ func runServ(k *cli.Context) { // for new branch refs, err = rep.AllReferencesMap() if err != nil { - println(err.Error()) + println("Get All References failed:", err.Error()) log.Error(err.Error()) return } @@ -257,7 +257,7 @@ func runServ(k *cli.Context) { } l, err = ref.AllCommits() if err != nil { - println(err.Error()) + println("Get All Commits failed:", err.Error()) log.Error(err.Error()) return } @@ -267,14 +267,14 @@ func runServ(k *cli.Context) { //log.Info("00000", ref.Oid.String()) last, err = ref.LastCommit() if err != nil { - println(err.Error()) + println("Get last commit failed:", err.Error()) log.Error(err.Error()) return } ref2, err := rep.LookupReference(ref.Name) if err != nil { - println(err.Error()) + println("look up reference failed:", err.Error()) log.Error(err.Error()) return } @@ -282,7 +282,7 @@ func runServ(k *cli.Context) { //log.Info("11111", ref2.Oid.String()) before, err := ref2.LastCommit() if err != nil { - println(err.Error()) + println("Get last commit failed:", err.Error()) log.Error(err.Error()) return } From 01b3b7004dfd7d70770ccd09a335db36c681a207 Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Tue, 25 Mar 2014 18:26:58 +0800 Subject: [PATCH 10/11] Init commit --- .gitignore | 22 ++++++++++++++++++++++ LICENSE | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..6cd1df2b7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..3af16b07244 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the {organization} nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file From 7048ea45279cd96f88845d83fe7cef6fbb545fcf Mon Sep 17 00:00:00 2001 From: skyblue Date: Tue, 25 Mar 2014 18:34:57 +0800 Subject: [PATCH 11/11] update avatar, remove gzip request header --- modules/avatar/avatar.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index 0ba20294afa..3b423a6d155 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -251,8 +251,8 @@ var client = &http.Client{} func (this *thunderTask) fetch() error { req, _ := http.NewRequest("GET", this.Url, nil) - req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") - req.Header.Set("Accept-Encoding", "gzip,deflate,sdch") + req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/jpeg,image/png,*/*;q=0.8") + req.Header.Set("Accept-Encoding", "deflate,sdch") req.Header.Set("Accept-Language", "zh-CN,zh;q=0.8") req.Header.Set("Cache-Control", "no-cache") req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36")