This commit is contained in:
xing 2022-11-10 18:15:19 +08:00
parent 4ceafe9c5f
commit af8033b80e

View File

@ -65,23 +65,27 @@ func PostComment(c *gin.Context) {
c.SetCookie(cookie.Name, cookie.Value, cookie.MaxAge, cookie.Path, cookie.Domain, cookie.Secure, cookie.HttpOnly) c.SetCookie(cookie.Name, cookie.Value, cookie.MaxAge, cookie.Path, cookie.Domain, cookie.Secure, cookie.HttpOnly)
} }
u := res.Header.Get("Location") u := res.Header.Get("Location")
up, err := url.Parse(u) up, er := url.Parse(u)
if err != nil { if er != nil {
err = er
return return
} }
cu, err := url.Parse(config.Conf.PostCommentUrl) cu, er := url.Parse(config.Conf.PostCommentUrl)
if err != nil { if er != nil {
err = er
return return
} }
up.Host = cu.Host up.Host = cu.Host
newReq, err := http.NewRequest("GET", up.String(), nil) up.Scheme = "http"
if err != nil { newReq, er := http.NewRequest("GET", up.String(), nil)
if er != nil {
err = er
return return
} }
newReq.Host = home.Host newReq.Host = home.Host
ress, err := http.DefaultClient.Do(newReq) ress, er := http.DefaultClient.Do(newReq)
if er != nil {
if err != nil { err = er
return return
} }
cc := c.Copy() cc := c.Copy()
@ -101,8 +105,9 @@ func PostComment(c *gin.Context) {
logs.ErrPrintln(err, "发送邮件", config.Conf.Mail.User, su, comment) logs.ErrPrintln(err, "发送邮件", config.Conf.Mail.User, su, comment)
}() }()
s, err := io.ReadAll(ress.Body) s, er := io.ReadAll(ress.Body)
if err != nil { if er != nil {
err = er
return return
} }
commentCache.Set(up.RawQuery, string(s)) commentCache.Set(up.RawQuery, string(s))
@ -115,3 +120,7 @@ func PostComment(c *gin.Context) {
} }
err = errors.New(string(s)) err = errors.New(string(s))
} }
func fetchContent() {
}