14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/brisk/server/proxy.rb', line 14
def rewrite_env(env)
request = BriskRequestHelper.new env
site = request.get_site
valet_home_path = request.valet_home_path
config = request.get_config
site_path = Site.get_site_paths(config, site)
if Server.is_running(valet_home_path)
if Site.read_site(valet_home_path) == site
if Site.is_secured?(config, site)
env["SERVER_PORT"] = "443" if env["SERVER_PORT"] == "80"
env["rack.url_scheme"] = "https" if env["rack.url_scheme"] == "http"
env["rack.ssl_verify_none"] = true
env["HTTP_HOST"] = "localhost:3003"
return env
end
env["HTTP_HOST"] = "localhost:3001"
return env
end
existing_pid = FileSystem.read("#{valet_home_path}/pid.txt") if FileSystem.file_exists?("#{valet_home_path}/pid.txt")
existing_pid = FileSystem.read("#{valet_home_path}/https_pid.txt") if Site.is_secured?(config, site)
puts existing_pid
Server.shutdown(existing_pid)
end
if Site.is_secured?(config, site)
Server.start_https(site_path)
started = Server.is_started(site_path)
if started
pid = Pid.read(site_path)
Pid.write_https(valet_home_path, pid)
Site.write_site(valet_home_path, site)
end
env["SERVER_PORT"] = "443" if env["SERVER_PORT"] == "80"
env["rack.url_scheme"] = "https" if env["rack.url_scheme"] == "http"
env["rack.ssl_verify_none"] = true
env["HTTP_HOST"] = "localhost:3003"
sleep(1)
return env
end
Server.start(site_path)
started = Server.is_started(site_path)
if started
pid = Pid.read(site_path)
Pid.write(valet_home_path, pid)
Site.write_site(valet_home_path, site)
end
run env
end
|