net-http-uploadprogress 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/net/http/uploadprogress.rb +52 -0
- data/lib/version.rb +3 -0
- data/net-http-uploadprogress.gemspec +24 -0
- metadata +51 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
|
4
|
+
module Net
|
5
|
+
class HTTP
|
6
|
+
def begin_transport(req)
|
7
|
+
if @socket.closed?
|
8
|
+
req.reset_upload_size
|
9
|
+
connect
|
10
|
+
end
|
11
|
+
if not req.response_body_permitted? and @close_on_empty_response
|
12
|
+
req['connection'] ||= 'close'
|
13
|
+
end
|
14
|
+
req['host'] ||= addr_port()
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class HTTPGenericRequest
|
19
|
+
def reset_upload_size
|
20
|
+
@upload_size = 0
|
21
|
+
end
|
22
|
+
|
23
|
+
def upload_size
|
24
|
+
@upload_size = 0 if @upload_size.nil?
|
25
|
+
@upload_size
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def send_request_with_body_stream(sock, ver, path, f)
|
31
|
+
unless content_length() or chunked?
|
32
|
+
raise ArgumentError,
|
33
|
+
"Content-Length not given and Transfer-Encoding is not `chunked'"
|
34
|
+
end
|
35
|
+
@upload_size = 0 if @upload_size.nil?
|
36
|
+
supply_default_content_type
|
37
|
+
write_header sock, ver, path
|
38
|
+
if chunked?
|
39
|
+
while s = f.read(1024)
|
40
|
+
@upload_size += s.length
|
41
|
+
sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
|
42
|
+
end
|
43
|
+
sock.write "0\r\n\r\n"
|
44
|
+
else
|
45
|
+
while s = f.read(1024)
|
46
|
+
@upload_size += s.length
|
47
|
+
sock.write s
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/version.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "net-http-uploadprogress"
|
7
|
+
s.version = NetHttpUploadprogress::VERSION
|
8
|
+
s.authors = ["SKAhack"]
|
9
|
+
s.email = ["m@skahack.com"]
|
10
|
+
s.homepage = "https://github.com/SKAhack/net-http-uploadprogress"
|
11
|
+
s.summary = %q{Get the file uploading progress.}
|
12
|
+
s.description = %q{Get the file uploading progress.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "net-http-uploadprogress"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: net-http-uploadprogress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SKAhack
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-25 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Get the file uploading progress.
|
15
|
+
email:
|
16
|
+
- m@skahack.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- Rakefile
|
24
|
+
- lib/net/http/uploadprogress.rb
|
25
|
+
- lib/version.rb
|
26
|
+
- net-http-uploadprogress.gemspec
|
27
|
+
homepage: https://github.com/SKAhack/net-http-uploadprogress
|
28
|
+
licenses: []
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project: net-http-uploadprogress
|
47
|
+
rubygems_version: 1.8.6
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: Get the file uploading progress.
|
51
|
+
test_files: []
|