File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -348,8 +348,13 @@ func (ctx *Context) RespHeader() http.Header {
348
348
// SetServeHeaders sets necessary content serve headers
349
349
func (ctx * Context ) SetServeHeaders (filename string ) {
350
350
ctx .Resp .Header ().Set ("Content-Description" , "File Transfer" )
351
- ctx .Resp .Header ().Set ("Content-Type" , "application/octet-stream" )
352
- ctx .Resp .Header ().Set ("Content-Disposition" , "attachment; filename=" + filename )
351
+ if strings .HasSuffix (filename , ".pdf" ) {
352
+ ctx .Resp .Header ().Set ("Content-Disposition" , "inline; filename=\" " + filename + "\" " )
353
+ ctx .Resp .Header ().Set ("Content-Type" , "application/pdf" )
354
+ } else {
355
+ ctx .Resp .Header ().Set ("Content-Type" , "application/octet-stream" )
356
+ ctx .Resp .Header ().Set ("Content-Disposition" , "attachment; filename=\" " + filename + "\" " )
357
+ }
353
358
ctx .Resp .Header ().Set ("Content-Transfer-Encoding" , "binary" )
354
359
ctx .Resp .Header ().Set ("Expires" , "0" )
355
360
ctx .Resp .Header ().Set ("Cache-Control" , "must-revalidate" )
You can’t perform that action at this time.
0 commit comments