- if (filename == null) {
- filename = url.getFile();
- host = url.getHost();
- port = url.getPort();
-
- InetAddress addr;
- try { addr = InetAddress.getByName(host); }
- catch (UnknownHostException uhe) { throw new JavaScriptException("could not resolve hostname \"" + host + "\""); }
- byte[] quadbyte = addr.getAddress();
-
- if (quadbyte[0] == 10 ||
- (quadbyte[0] == 192 && quadbyte[1] == 168) ||
- (quadbyte[0] == 172 && (quadbyte[1] & 0xF0) == 16) &&
- !addr.equals(Main.originAddr)) {
- filename = null;
- throw new JavaScriptException("security violation: " + host + " [" + addr.getHostAddress() + "] is in a firewalled netblock");
- }
- }
-
- Socket s;
- if (ssl) s = Platform.getSocket(host, port == -1 ? 443 : port, true);
- else if (url.getProtocol().equals("http")) s = Platform.getSocket(host, port == -1 ? 80 : port, false);
- else throw new JavaScriptException("only http[s] is supported");
-
- s.setTcpNoDelay(true);
- OutputStream os = new BufferedOutputStream(s.getOutputStream(), 4000);
- InputStream is = new BufferedInputStream(new Filter(s.getInputStream()));
-
- PrintWriter ps;
- if (!Log.verbose) ps = new PrintWriter(os);
- else ps = new PrintWriter(new FilterWriter(new OutputStreamWriter(os)) {
- public void write(int i) throws IOException {
- super.write(i);
- if (Log.on) Log.log(this, "send: " + ((char)i));
- }
- public void write(String s, int start, int len) throws IOException {
- super.write(s, start, len);
- if (Log.on) Log.log(this, "send: " + s.substring(start, start + len));
- }
- public void write(char[] c, int start, int len) throws IOException {
- super.write(c, start, len);
- if (Log.on) Log.log(this, "send: " + new String(c, start, len));
- }
- });
+ if (Log.verbose) Log.log(this, "call to " + url + " : " + methodname);
+ HTTP http = new HTTP(url);
+ String content = send(args, http);
+ OutputStream os = new BufferedOutputStream(http.getOutputStream(content.length(), "text/xml"), 4000);
+ PrintWriter ps = !Log.verbose ?
+ new PrintWriter(os) :
+ new PrintWriter(new FilterWriter(os)) {
+ public void write(int i) throws IOException {
+ super.write(i);
+ if (Log.on) Log.log(this, "send: " + ((char)i));
+ }
+ public void write(String s, int start, int len) throws IOException {
+ super.write(s, start, len);
+ if (Log.on) Log.log(this, "send: " + s.substring(start, start + len));
+ }
+ public void write(char[] c, int start, int len) throws IOException {
+ super.write(c, start, len);
+ if (Log.on) Log.log(this, "send: " + new String(c, start, len));
+ }
+ });
+ ps.print(content.toString());
+ ps.flush();