Cookies can be set in response to return non-HTML pages, such as JPG or zip.
Setting Cookieresponse's eader explains which cookies the browser needs to remember. See.
Io.netty.handler.codec.http.DefaultCookie.Defaultcookie(string name, String value)
Create a cookie.
Httpheaders Io.netty.handler.codec.http.HttpMessage.Headers()
Returns the header of an HTTP message.
Httpheaders io.netty.handler.codec.http.HttpHeaders.Set(charsequence name, Object value)
Sets the key-value pair for the header.
Charsequence Io.netty.handler.codec.http.HttpHeaders.Names.Set_cookie
A string constant with the content "Set-cookie".
String Io.netty.handler.codec.http.ClientCookieEncoder.encode(Cookie cookie)
The cookie structure is encoded as a string so that it is placed in the HttpResponse header.
Sample
Back to other content such as pictures 1. Setting the head
Response.headers ().Set(Content_Type, "MAGE/JPEG; Charset=utf-8 ");//description content as Picture
2. Writing binary data
Bytebuf Io.netty.buffer.ByteBuf.writebytes(Bytebuf src)
The byte is first converted to Bytebuf, and then the binary data is written by this method.
Netty-http-response