diff --git a/HISTORY.md b/HISTORY.md
index 21c6f621..c7f89e9b 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -2,6 +2,13 @@
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
+
+## 6.0.3 -> 6.0.4
+
+- Add a simple `context.StreamWriter` to fill the v5's StreamWriter, it's a `io.Writer` instead of `bufio.Writer` and returns false when stop otherwise true. Take a look at the silly book examples [here](https://docs.iris-go.com/streaming).
+
+
+
## 6.0.2 -> 6.0.3
- Give the users an easy to way to set a limit to the body size comes from the client, globally or per-route (useful when you want to disable/enable limit on certain clients).
diff --git a/README.md b/README.md
index 466c7605..312033ae 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@
-
+
@@ -823,7 +823,7 @@ I recommend writing your API tests using this new library, [httpexpect](https://
Versioning
------------
-Current: **v6.0.3**
+Current: **v6.0.4**
Stable: **[v5/fasthttp](https://github.com/kataras/iris/tree/5.0.0)**
diff --git a/context.go b/context.go
index dc637357..54588ae3 100644
--- a/context.go
+++ b/context.go
@@ -68,15 +68,6 @@ const (
stopExecutionPosition = 255
)
-// errors
-
-var (
- errTemplateExecute = errors.New("Unable to execute a template. Trace: %s")
- errFlashNotFound = errors.New("Unable to get flash message. Trace: Cookie does not exists")
- errReadBody = errors.New("While trying to read %s from the request body. Trace %s")
- errServeContent = errors.New("While trying to serve content to the client. Trace %s")
-)
-
type (
requestValue struct {
key []byte
@@ -384,6 +375,12 @@ func (ctx *Context) FormFile(key string) (multipart.File, *multipart.FileHeader,
return ctx.Request.FormFile(key)
}
+var (
+ errTemplateExecute = errors.New("Unable to execute a template. Trace: %s")
+ errReadBody = errors.New("While trying to read %s from the request body. Trace %s")
+ errServeContent = errors.New("While trying to serve content to the client. Trace %s")
+)
+
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
// -----------------------------Request Body Binders/Readers----------------------------
@@ -515,10 +512,6 @@ func (ctx *Context) SetStatusCode(statusCode int) {
ctx.ResponseWriter.WriteHeader(statusCode)
}
-// it used only inside Redirect,
-// keep it here for allocations reason
-var httpsSchemeOnlyBytes = []byte("https")
-
// Redirect redirect sends a redirect response the client
// accepts 2 parameters string and an optional int
// first parameter is the url to redirect
@@ -608,6 +601,7 @@ func (ctx *Context) WriteGzip(b []byte) (int, error) {
} // else write the contents as it is? no let's create a new func for this
return n, err
}
+
return 0, errClientDoesNotSupportGzip
}
@@ -870,6 +864,38 @@ func (ctx *Context) SendFile(filename string, destinationName string) {
ctx.ResponseWriter.Header().Set(contentDisposition, "attachment;filename="+destinationName)
}
+// StreamWriter registers the given stream writer for populating
+// response body.
+//
+// Access to context's and/or its' members is forbidden from writer.
+//
+// This function may be used in the following cases:
+//
+// * if response body is too big (more than iris.LimitRequestBodySize(if setted)).
+// * if response body is streamed from slow external sources.
+// * if response body must be streamed to the client in chunks.
+// (aka `http server push`).
+//
+// receives a function which receives the response writer
+// and returns false when it should stop writing, otherwise true in order to continue
+func (ctx *Context) StreamWriter(writer func(w io.Writer) bool) {
+ w := ctx.ResponseWriter
+ notifyClosed := w.CloseNotify()
+ for {
+ select {
+ // response writer forced to close, exit.
+ case <-notifyClosed:
+ return
+ default:
+ shouldContinue := writer(w)
+ w.Flush()
+ if !shouldContinue {
+ return
+ }
+ }
+ }
+}
+
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
// --------------------------------Storage----------------------------------------------
diff --git a/iris.go b/iris.go
index 9e428a67..78bbf0b9 100644
--- a/iris.go
+++ b/iris.go
@@ -81,7 +81,7 @@ const (
// IsLongTermSupport flag is true when the below version number is a long-term-support version
IsLongTermSupport = false
// Version is the current version number of the Iris web framework
- Version = "6.0.3"
+ Version = "6.0.4"
banner = ` _____ _
|_ _| (_)
diff --git a/response_recorder.go b/response_recorder.go
index c5e45e18..43f1a84d 100644
--- a/response_recorder.go
+++ b/response_recorder.go
@@ -157,6 +157,7 @@ func (w *ResponseRecorder) flushResponse() {
func (w *ResponseRecorder) Flush() {
w.flushResponse()
w.responseWriter.Flush()
+ w.ResetBody()
}
// clone returns a clone of this response writer