douxitao8170 2016-07-04 13:14
浏览 251

Safari在重定向期间重新加载网页3次

For the life of me I thought I was going mad because as far as I could see everything was/is ok with the code in that regards. Out of exasperation I decided to try my application in another browser and found that in Chrome and FF the app works fine, but in Safari for some reason it refreshes the page 3 times. I've tried resetting Safari and turning off extensions in case that was the issue but the same thing happens.

I'm not sure if this is just a quirk with my setup, or potentially my code so I've pasted it here below to have some other eyes look at it. If more code/context is required, please let me know. In essence it takes the user to the index page, the movie page and repeats this process 3 times.

func movieHandler(w http.ResponseWriter, r *http.Request) {
    command := r.URL.Query().Get("command")
    film := r.URL.Query().Get("movie")

    if pageData.Player.Playing == false {
        if film == "" {
            log.Println("No film was selected")
            http.Redirect(w, r, "/", http.StatusFound)
            return
        }
        err := pageData.Player.StartFilm(film)
        if err != nil {
            log.Printf("Following error occurred: %v
", err)
            http.Redirect(w, r, "/", http.StatusFound)
            return
        }
        pageData.CurrentFilm = film
    } else if pageData.Player.Playing && (film == "" || pageData.Player.FilmName == film) {
        if command == "kill" {
            err := pageData.Player.EndFilm()
            if err != nil {
                log.Printf("Following error occurred: %v
", err)
            }
            http.Redirect(w, r, "/", http.StatusFound)
            return
        } else if command != "" {
            err := pageData.Player.SendCommandToFilm(command)
            if err != nil {
                log.Printf("Following error occurred: %v
", err)
            }
        }
    } else {
        http.Redirect(w, r, "/", http.StatusFound)
        return
    }
    renderTemplate(w, "movie.html")
}

Note: I'm still an inexperienced coder (especially with go), so additional input on improving this code in any other way is appreciated.

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料