第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在 Golang 中,是 http.HandleFunc 塊嗎?

在 Golang 中,是 http.HandleFunc 塊嗎?

Go
慕慕森 2021-06-15 17:01:49
我在 Golang 中編寫了一個(gè) httpserver,但是我發(fā)現(xiàn)當(dāng)來自 Web 瀏覽器的多個(gè)請(qǐng)求時(shí) http.HandleFunc 將被阻止。我怎樣才能讓服務(wù)器同時(shí)處理多個(gè)請(qǐng)求?謝謝。我的代碼是:func DoQuery(w http.ResponseWriter, r *http.Request) {    r.ParseForm()    fmt.Printf("%d path %s\n", time.Now().Unix(), r.URL.Path)    time.Sleep(10 * time.Second)    fmt.Fprintf(w, "hello...")    //why this function block when multi request ?}func main() {    fmt.Printf("server start working...\n")    http.HandleFunc("/query", DoQuery)    s := &http.Server{        Addr:         ":9090",        ReadTimeout:  30 * time.Second,        WriteTimeout: 30 * time.Second,        //MaxHeaderBytes: 1 << 20,    }    log.Fatal(s.ListenAndServe())    fmt.Printf("server stop...")}我運(yùn)行了你的代碼,一切都按預(yù)期工作。我同時(shí)做了兩個(gè)請(qǐng)求(curl localhost:9090/query),它們都在 10 秒后完成。也許問題出在其他地方?這是我使用的命令: time curl -s localhost:9090/query | echo $(curl -s localhost:9090/query) – tjameson塔肯斯那很奇怪。當(dāng)我從 chrome 請(qǐng)求相同的 url 時(shí),發(fā)送兩個(gè)請(qǐng)求不是同時(shí)處理,但使用 cur 測(cè)試可以同時(shí)處理。但是當(dāng)我發(fā)送兩個(gè)請(qǐng)求使用不同的 url 時(shí),它可以同時(shí)處理。[root@localhost httpserver]# ./httpServer服務(wù)器開始工作...1374301593 路徑 /query?form=chrome1374301612 路徑 /query?from=cur21374301614 路徑 /query?from=cur11374301618 路徑 /query?form=chrome1374301640 路徑 /query?form=chrome21374301643 路徑 /query?form=chrome1*1374301715 路徑 /query?form=chrome1374301725 路徑 /query?form=chrome***1374301761 路徑 /query?form=chrome11374301763 路徑 /query?form=chrome2**
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 185 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)