mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	helpers: Support building without_zlib
This commit is contained in:
		
							parent
							
								
									cb9adcd188
								
							
						
					
					
						commit
						75e0ae30a0
					
				
					 1 changed files with 31 additions and 26 deletions
				
			
		| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %}
 | 
					{% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 && !flag?(:without_zlib) %}
 | 
				
			||||||
  require "compress/deflate"
 | 
					  require "compress/deflate"
 | 
				
			||||||
  require "compress/gzip"
 | 
					  require "compress/gzip"
 | 
				
			||||||
{% end %}
 | 
					{% end %}
 | 
				
			||||||
| 
						 | 
					@ -141,6 +141,10 @@ def send_file(env : HTTP::Server::Context, path : String, mime_type : String? =
 | 
				
			||||||
      next multipart(file, env)
 | 
					      next multipart(file, env)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {% if flag?(:without_zlib) %}
 | 
				
			||||||
 | 
					      env.response.content_length = filesize
 | 
				
			||||||
 | 
					      IO.copy(file, env.response)
 | 
				
			||||||
 | 
					    {% else %}
 | 
				
			||||||
      condition = config.is_a?(Hash) && config["gzip"]? == true && filesize > minsize && Kemal::Utils.zip_types(file_path)
 | 
					      condition = config.is_a?(Hash) && config["gzip"]? == true && filesize > minsize && Kemal::Utils.zip_types(file_path)
 | 
				
			||||||
      if condition && request_headers.includes_word?("Accept-Encoding", "gzip")
 | 
					      if condition && request_headers.includes_word?("Accept-Encoding", "gzip")
 | 
				
			||||||
        env.response.headers["Content-Encoding"] = "gzip"
 | 
					        env.response.headers["Content-Encoding"] = "gzip"
 | 
				
			||||||
| 
						 | 
					@ -168,6 +172,7 @@ def send_file(env : HTTP::Server::Context, path : String, mime_type : String? =
 | 
				
			||||||
        env.response.content_length = filesize
 | 
					        env.response.content_length = filesize
 | 
				
			||||||
        IO.copy(file, env.response)
 | 
					        IO.copy(file, env.response)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					    {% end %}
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  return
 | 
					  return
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue