|
40 | 40 | obj.Specs.Host = 'http://stream.plot.ly'; |
41 | 41 | end |
42 | 42 |
|
| 43 | + %check if ssl is enabled |
| 44 | + if any(strfind(obj.Specs.Host,'https://') == 1) |
| 45 | + obj.Specs.SSLEnabled = true; |
| 46 | + else |
| 47 | + obj.Specs.SSLEnabled = false; |
| 48 | + end |
| 49 | + |
| 50 | + %add http if not present on host |
| 51 | + if ~obj.Specs.SSLEnabled |
| 52 | + if ~any(strfind(obj.Specs.Host,'http://') == 1) |
| 53 | + obj.Specs.Host = ['http://' obj.Specs.Host]; |
| 54 | + end |
| 55 | + end |
| 56 | + |
| 57 | + %specify handler |
| 58 | + if obj.Specs.SSLEnabled |
| 59 | + obj.Specs.Handler = sun.net.www.protocol.https.Handler; |
| 60 | + else |
| 61 | + obj.Specs.Handler = sun.net.www.protocol.http.Handler; |
| 62 | + end |
| 63 | + |
43 | 64 | %initialize connection settings |
44 | | - obj.Specs.Port = 80; |
45 | 65 | obj.Specs.ReconnectOn = {'','200','408'}; |
46 | 66 | obj.Specs.Timeout = 500; |
47 | | - obj.Specs.Handler = sun.net.www.protocol.http.Handler; |
48 | 67 | obj.Specs.Chunklen = 14; |
49 | 68 | obj.Specs.Closed = true; |
50 | 69 | obj.Specs.ConnectAttempts = 0; |
|
76 | 95 | obj.Specs.Host = request.host; |
77 | 96 | end |
78 | 97 |
|
79 | | - if (isfield(request,'port')) |
80 | | - obj.Specs.Port = request.port; |
81 | | - end |
82 | | - |
83 | | - if obj.Specs.Port ~=80 |
84 | | - obj.Specs.Host = [obj.Specs.Host ':' num2str(obj.Specs.Port)]; |
85 | | - end |
86 | | - |
87 | 98 | if isfield(request,'timeout') |
88 | 99 | obj.Specs.Timeout = request.timeout; |
89 | 100 | end |
|
107 | 118 | 'online documentation found @ plot.ly/matlab for more information or contact ',... |
108 | 119 | 'chuck@plot.ly']); |
109 | 120 | end |
110 | | - |
111 | | - %add http if not present on host |
112 | | - if ~any(strfind(obj.Specs.Host,'http://') == 1) |
113 | | - obj.Specs.Host = ['http://' obj.Specs.Host]; |
114 | | - end |
115 | | - |
116 | 121 | end |
117 | 122 |
|
118 | 123 | %-----------OPEN STREAM-----------% |
|
139 | 144 | %-----------CONNECT TO STREAM-----------% |
140 | 145 | function obj = connect(obj) |
141 | 146 | obj.URL = java.net.URL([],obj.Specs.Host,obj.Specs.Handler); |
142 | | - obj.Connection = obj.URL.openConnection; %throws an I/O exception |
| 147 | + |
| 148 | + % Get the proxy information using MathWorks facilities for unified proxy |
| 149 | + % preference settings. |
| 150 | + mwtcp = com.mathworks.net.transport.MWTransportClientPropertiesFactory.create(); |
| 151 | + proxy = mwtcp.getProxy(); |
| 152 | + |
| 153 | + % Open a connection to the URL. |
| 154 | + if isempty(proxy) |
| 155 | + obj.Connection = obj.URL.openConnection(); %throws an I/O exception |
| 156 | + else |
| 157 | + obj.Connection = obj.URL.openConnection(proxy); %throws an I/O exception |
| 158 | + end |
| 159 | + |
143 | 160 | obj.Connection.setChunkedStreamingMode(obj.Specs.Chunklen) |
144 | 161 | obj.Connection.setRequestMethod('POST'); |
145 | 162 | obj.Connection.setDoOutput(true); |
|
0 commit comments