I've written some simple js functions to do HTTP Get, Post, Put and
Delete requests using java.net.URL.

However, whereas Curl or the browser can make the same request in
under 1 second, my implementation in Rhino/Java takes 4 seconds on
average. I've traced the bulk of this time to the following code I use
to read the response:

try {
  var stream = new java.io.InputStreamReader
(this.connection.getInputStream(), 'UTF-8');
} catch (e) {
  var stream = new java.io.InputStreamReader
(this.connection.getErrorStream(), 'UTF-8');
}
var input = new java.io.BufferedReader(stream);
if (input) {
  var line = '';
  while ((line = input.readLine()) !== null) {
    this.response.representation += line;
  }
  this.response.representation += ''; // Convert to Javascript string.
  input.close();
}

The response being processed with this is about 244kb and as mentioned
it's about 3 seconds slower than Curl or browser.

Would anyone have any suggestions? Help would be much appreciated.
Thanks.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to