rack-http-pipe 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 56f9e182ed310994a0395d2226a9c332b12234f6
4
+ data.tar.gz: 684a323590ca7270a4546aa99bc8a16cc870526d
5
+ SHA512:
6
+ metadata.gz: cc2112683f510b049ffa724a210d3f7372ae509240964d65f5b3d85b5241dff1b8445e3a4d4888b84644d3f5d69a910e3ed593a5bdf9d21a6cbde3285851414d
7
+ data.tar.gz: 1c4ee7992df04c320f1e0f0b38fa9f426e9ad4bd42453f751bc31b6c40cb8b1287db1536a3a458207d180d2d95bc8cbdb446ba93252f0de392602637b2447ae9
@@ -0,0 +1,13 @@
1
+ require 'sinatra'
2
+ require 'pry'
3
+ require '../lib/rack/http-pipe'
4
+
5
+ class ExampleApp < Sinatra::Application
6
+ helpers Rack::HttpPipe
7
+
8
+ get "/" do
9
+ http_pipe "http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-desktop-amd64.iso"
10
+ end
11
+ end
12
+
13
+ ExampleApp.run
@@ -0,0 +1,2 @@
1
+ require File.expand_path("../http-pipe/pipe.rb", __FILE__)
2
+
@@ -0,0 +1,27 @@
1
+ require 'uri'
2
+
3
+ module Rack
4
+ module HttpPipe
5
+ def http_pipe(url, opts = {})
6
+ st = opts.fetch(:status, 200)
7
+ uri = URI(url)
8
+
9
+ status st
10
+ if opts[:headers] and opts[:headers].is_a? Hash
11
+ headers opts[:headers]
12
+ end
13
+
14
+ stream do
15
+ Net::HTTP.start(uri.host, uri.port) do |http|
16
+ req = Net::HTTP::Get.new(uri.request_uri)
17
+ req.basic_auth uri.user, uri.password
18
+ http.request req do |res|
19
+ res.read_body do |c|
20
+ response.write c
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-http-pipe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Léo Unbekandt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ description: |
28
+ # Rack HTTP Pipe
29
+
30
+ Use to pipe directly a remote HTTP file without buffering it.
31
+
32
+ > /!\ Do not work with WebBrick, tested with puma
33
+
34
+ ## Use case
35
+
36
+ * Given a file named #HASH#.pdf on S3
37
+ * You want a clean URL and handling the authentication in front of it
38
+
39
+ ```
40
+ GET http:/example.com/download
41
+
42
+ Content-Disposition: attachment;filename=name-fetched-from-db.pdf
43
+ Content-Length
44
+ Content-Type
45
+ etc.
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ```ruby
51
+ get "/" do
52
+ http_pipe "http://example.com/iso-ubuntu-1404-64bits", {
53
+ status: 200,
54
+ headers: {
55
+ "Content-Type: application/octet-stream",
56
+ "Content-Disposition: attachment;filename=ubuntu.iso",
57
+ }
58
+ }
59
+ end
60
+ ```
61
+
62
+ See the example directory for an example app using sinatra
63
+ email: leo@scalingo.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - example/app.rb
69
+ - lib/rack/http-pipe.rb
70
+ - lib/rack/http-pipe/pipe.rb
71
+ homepage: http://github.com/Scalingo/rack-http-pipe
72
+ licenses:
73
+ - BSD
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.5
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Stripe remote HTTP resource to server client
95
+ test_files: []