本文整理匯總了Golang中net/http/httptest.ResponseRecorder.Flush方法的典型用法代碼示例。如果您正苦於以下問題:Golang ResponseRecorder.Flush方法的具體用法?Golang ResponseRecorder.Flush怎麽用?Golang ResponseRecorder.Flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net/http/httptest.ResponseRecorder
的用法示例。
在下文中一共展示了ResponseRecorder.Flush方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: writeRecorder
// Write the contents of a ResponseRecorder to a ResponseWriter
func writeRecorder(w http.ResponseWriter, recorder *httptest.ResponseRecorder) {
for key, values := range recorder.HeaderMap {
for _, value := range values {
w.Header().Set(key, value)
}
}
recorder.Body.WriteTo(w)
recorder.Flush()
}
示例2: recorderToString
// Discards the HTTP headers and returns the recorder body as a string
func recorderToString(recorder *httptest.ResponseRecorder) string {
var buf bytes.Buffer
recorder.Body.WriteTo(&buf)
recorder.Flush()
return buf.String()
}