Skip to content

Commit

Permalink
https://github.com/iris-contrib/gitbook/issues/30
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Jan 5, 2017
1 parent d5a9410 commit d060a73
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 16 deletions.
7 changes: 7 additions & 0 deletions HISTORY.md
Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -20,7 +20,7 @@
<br/>


<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%206.0.3%20-blue.svg?style=flat-square" alt="Releases"></a>
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%206.0.4%20-blue.svg?style=flat-square" alt="Releases"></a>

<a href="https://github.com/iris-contrib/examples"><img src="https://img.shields.io/badge/%20examples-repository-3362c2.svg?style=flat-square" alt="Examples"></a>

Expand Down Expand Up @@ -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)**

Expand Down
52 changes: 39 additions & 13 deletions context.go
Expand Up @@ -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
Expand Down Expand Up @@ -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----------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion iris.go
Expand Up @@ -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 = ` _____ _
|_ _| (_)
Expand Down
1 change: 1 addition & 0 deletions response_recorder.go
Expand Up @@ -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
Expand Down

0 comments on commit d060a73

Please sign in to comment.