- OutputStream os = new BufferedOutputStream(http.getOutputStream(content.length(), "text/xml"), 4000);
- PrintWriter ps = !Log.verbose ?
- new PrintWriter(os) :
- 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));
- }
- });
- ps.print(content.toString());
- ps.flush();
-
- BufferedReader br = !Log.verbose ?
- new BufferedReader(new InputStreamReader(new Filter(http.getInputStream()))) :
- new BufferedReader(new FilterReader(new InputStreamReader(new Filter(http.getInputStream()))) {
- public int read() throws IOException {
- int i = super.read();
- if (Log.on) Log.log(this, "recv: " + ((char)i));
- return i;
- }
- public int read(char[] c, int off, int len) throws IOException {
- int ret = super.read(c, off, len);
- if (ret == -1) return ret;
- if (Log.on) Log.log(this, "recv: " + new String(c, off, ret));
- return ret;
- }
- });
- return recieve(br);
+ if (Log.verbose) Log.log(this, "send: " + content);
+
+ HTTP.HTTPInputStream is = http.POST("text/xml", content);
+ try {
+ BufferedReader br = !Log.verbose ?
+ new BufferedReader(new InputStreamReader(new Filter(is))) :
+ new BufferedReader(new FilterReader(new InputStreamReader(new Filter(is))) {
+ public int read() throws IOException {
+ int i = super.read();
+ if (Log.on) Log.log(this, "recv: " + ((char)i));
+ return i;
+ }
+ public int read(char[] c, int off, int len) throws IOException {
+ int ret = super.read(c, off, len);
+ if (ret == -1) return ret;
+ String s;
+ BufferedReader br2 = new BufferedReader(new StringReader(new String(c, off, ret)));
+ while ((s = br2.readLine()) != null) if (Log.on) Log.log(this, "recv: " + s);
+ return ret;
+ }
+ });
+ return recieve(br);
+ } finally {
+ is.close();
+ }