You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2006/10/15 15:42:29 UTC
svn commit: r464194 - in
/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl:
HttpMessage.java HttpRequest.java ReactorTester.java ReadHandler.java
Author: asankha
Date: Sun Oct 15 06:42:29 2006
New Revision: 464194
URL: http://svn.apache.org/viewvc?view=rev&rev=464194
Log:
checkin sample for GET before https support is added
Modified:
incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpMessage.java
incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpRequest.java
incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReactorTester.java
incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java
Modified: incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpMessage.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpMessage.java?view=diff&rev=464194&r1=464193&r2=464194
==============================================================================
--- incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpMessage.java (original)
+++ incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpMessage.java Sun Oct 15 06:42:29 2006
@@ -207,7 +207,7 @@
Iterator iter = headers.keySet().iterator();
while (iter.hasNext()) {
String headerName = (String) iter.next();
- sb.append(headerName + Constants.STRING_COLON +
+ sb.append(headerName + Constants.STRING_COLON + Constants.STRING_SP +
headers.get(headerName) + Constants.CRLF);
}
sb.append(Constants.CRLF);
Modified: incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpRequest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpRequest.java?view=diff&rev=464194&r1=464193&r2=464194
==============================================================================
--- incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpRequest.java (original)
+++ incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/HttpRequest.java Sun Oct 15 06:42:29 2006
@@ -40,6 +40,7 @@
private String method;
private String protocol;
private Map requestParams;
+ private boolean secure = false;
/** A pointer to a runnable to be executed once a response is received for this httpMessage */
private Runnable onResponse = null;
@@ -111,6 +112,15 @@
return path;
}
+
+ public boolean isSecure() {
+ return secure;
+ }
+
+ public void setSecure(boolean secure) {
+ this.secure = secure;
+ }
+
public void setPath(String path) {
this.path = path;
requestParams = new HashMap();
@@ -170,6 +180,14 @@
} else {
return Constants.CLOSE.equals(headers.get(Constants.CONNECTION));
}
+ }
+
+ /**
+ * Causes the request to contain an empty body (i.e. for a GET etc)
+ */
+ public void setEmptyBody() {
+ buffer.position(bodyStart);
+ buffer.flip();
}
//------------------------------ TESTING CODE ------------------------
Modified: incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReactorTester.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReactorTester.java?view=diff&rev=464194&r1=464193&r2=464194
==============================================================================
--- incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReactorTester.java (original)
+++ incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReactorTester.java Sun Oct 15 06:42:29 2006
@@ -24,8 +24,33 @@
public static void main(String[] args) throws Exception {
ReactorTester rt = new ReactorTester();
- rt.runDemo();
+ //rt.runDemo();
+ rt.simpleGet();
}
+
+ private void simpleGet() throws IOException {
+ HttpRequest request = new HttpRequest(
+ new URL("https://localhost:8443/"));
+ request.setMethod(Constants.GET);
+ request.addHeader("Host", "127.0.0.1:8443");
+ request.setEmptyBody();
+ request.setSecure(true);
+ request.setConnectionClose();
+
+ r = Reactor.createReactor(null, 9001, false, new HttpService() {
+ public void handleRequest(HttpRequest request) {
+ System.out.println("?");
+ }
+
+ public void handleResponse(HttpResponse response, Runnable callback) {
+ System.out.println("Response : " + response);
+ }
+ });
+ new Thread(r).start();
+ r.send(request, null);
+ }
+
+
private void runDemo() throws IOException {
Modified: incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java?view=diff&rev=464194&r1=464193&r2=464194
==============================================================================
--- incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java (original)
+++ incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java Sun Oct 15 06:42:29 2006
@@ -111,6 +111,13 @@
// set position within buffer to read from channel
buffer.position(readPos);
+ if (readPos == buffer.capacity()) {
+ ByteBuffer newBuf = ByteBuffer.allocate(buffer.capacity() * 2);
+ log.debug("Expanding ByteBuffer to " + newBuf.capacity() + " bytes");
+ buffer.flip();
+ buffer = newBuf.put(buffer);
+ }
+
// perform read from channel to this location
int bytesRead = socket.read(buffer);
if (bytesRead == -1) {
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org