mirror of
				https://gitea.invidious.io/iv-org/shard-kemal.git
				synced 2024-08-15 00:53:36 +00:00 
			
		
		
		
	Remove env.params.files and FileUpload
This commit is contained in:
		
							parent
							
								
									d2ef57a128
								
							
						
					
					
						commit
						4a58bc9690
					
				
					 2 changed files with 0 additions and 43 deletions
				
			
		|  | @ -1,25 +0,0 @@ | ||||||
| module Kemal |  | ||||||
|   # :nodoc: |  | ||||||
|   struct FileUpload |  | ||||||
|     getter tmpfile : Tempfile |  | ||||||
|     getter filename : String? |  | ||||||
|     getter headers : HTTP::Headers |  | ||||||
|     getter creation_time : Time? |  | ||||||
|     getter modification_time : Time? |  | ||||||
|     getter read_time : Time? |  | ||||||
|     getter size : UInt64? |  | ||||||
| 
 |  | ||||||
|     def initialize(upload) |  | ||||||
|       @tmpfile = Tempfile.new(filename) |  | ||||||
|       ::File.open(@tmpfile.path, "w") do |file| |  | ||||||
|         IO.copy(upload.body, file) |  | ||||||
|       end |  | ||||||
|       @filename = upload.filename |  | ||||||
|       @headers = upload.headers |  | ||||||
|       @creation_time = upload.creation_time |  | ||||||
|       @modification_time = upload.modification_time |  | ||||||
|       @read_time = upload.read_time |  | ||||||
|       @size = upload.size |  | ||||||
|     end |  | ||||||
|   end |  | ||||||
| end |  | ||||||
|  | @ -9,13 +9,11 @@ module Kemal | ||||||
|     PARTS            = %w(url query body json) |     PARTS            = %w(url query body json) | ||||||
|     # :nodoc: |     # :nodoc: | ||||||
|     alias AllParamTypes = Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Any) | Array(JSON::Any) |     alias AllParamTypes = Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Any) | Array(JSON::Any) | ||||||
|     getter files |  | ||||||
| 
 | 
 | ||||||
|     def initialize(@request : HTTP::Request, @url : Hash(String, String) = {} of String => String) |     def initialize(@request : HTTP::Request, @url : Hash(String, String) = {} of String => String) | ||||||
|       @query = HTTP::Params.new({} of String => Array(String)) |       @query = HTTP::Params.new({} of String => Array(String)) | ||||||
|       @body = HTTP::Params.new({} of String => Array(String)) |       @body = HTTP::Params.new({} of String => Array(String)) | ||||||
|       @json = {} of String => AllParamTypes |       @json = {} of String => AllParamTypes | ||||||
|       @files = [] of FileUpload |  | ||||||
|       @url_parsed = false |       @url_parsed = false | ||||||
|       @query_parsed = false |       @query_parsed = false | ||||||
|       @body_parsed = false |       @body_parsed = false | ||||||
|  | @ -47,10 +45,6 @@ module Kemal | ||||||
|         @body = parse_part(@request.body) |         @body = parse_part(@request.body) | ||||||
|         return |         return | ||||||
|       end |       end | ||||||
|       if content_type.try(&.starts_with?(MULTIPART_FORM)) |  | ||||||
|         parse_file_upload |  | ||||||
|         return |  | ||||||
|       end |  | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     private def parse_query |     private def parse_query | ||||||
|  | @ -61,18 +55,6 @@ module Kemal | ||||||
|       @url.each { |key, value| @url[key] = unescape_url_param(value) } |       @url.each { |key, value| @url[key] = unescape_url_param(value) } | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     private def parse_file_upload |  | ||||||
|       HTTP::FormData.parse(@request) do |upload| |  | ||||||
|         next unless upload |  | ||||||
|         filename = upload.filename |  | ||||||
|         if !filename.nil? |  | ||||||
|           @files << FileUpload.new(upload: upload) |  | ||||||
|         else |  | ||||||
|           @body.add(upload.name, upload.body.gets_to_end) |  | ||||||
|         end |  | ||||||
|       end |  | ||||||
|     end |  | ||||||
| 
 |  | ||||||
|     # Parses JSON request body if Content-Type is `application/json`. |     # Parses JSON request body if Content-Type is `application/json`. | ||||||
|     # |     # | ||||||
|     # - If request body is a JSON `Hash` then all the params are parsed and added into `params`. |     # - If request body is a JSON `Hash` then all the params are parsed and added into `params`. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue