[Webfunds-commits] java/webfunds/comms RawHttp.java

Ian Grigg iang@cypherpunks.ai
Sun, 8 Apr 2001 15:14:24 -0400 (AST)


iang        01/04/08 15:14:24

  Modified:    webfunds/comms RawHttp.java
  Log:
  added the extra empty line to the GET;  fixed the URL port default to 80

Revision  Changes    Path
1.10      +10 -4     java/webfunds/comms/RawHttp.java

Index: RawHttp.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/comms/RawHttp.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- RawHttp.java	2001/04/06 22:47:18	1.9
+++ RawHttp.java	2001/04/08 19:14:24	1.10
@@ -1,5 +1,5 @@
 /*
- * $Id: RawHttp.java,v 1.9 2001/04/06 22:47:18 iang Exp $
+ * $Id: RawHttp.java,v 1.10 2001/04/08 19:14:24 iang Exp $
  *
  * Copyright (c) 2000 Systemics Inc on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -425,13 +425,14 @@
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
-        String Host = HOSTC + whereTo + end;
         String Get = "GET " + page + " HTTP/1.1" + end;
+        String Host = HOSTC + whereTo + end;
 
         try
         {
             baos.write(Get.getBytes());       // GET /page HTTP/1.1
             baos.write(Host.getBytes());      // Host: foo.bar
+            baos.write(end.getBytes());       // extra end
             baos.write(CON_CLOSE.getBytes()); // kills the Java socket?
             baos.write(end.getBytes());       // extra line terminates...
         }
@@ -455,13 +456,14 @@
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
-        String Host = HOSTC + host + ":" + port + end;
         String Get = "GET " + page + " HTTP/1.1" + end;
+        String Host = HOSTC + host + ":" + port + end;
 
         try
         {
             baos.write(Get.getBytes());       // GET /page HTTP/1.1
             baos.write(Host.getBytes());      // Host: foo.bar
+            baos.write(end.getBytes());       // extra end
             baos.write(CON_CLOSE.getBytes()); // kills the Java socket?
             baos.write(end.getBytes());       // extra line terminates...
         }
@@ -483,7 +485,11 @@
 
     public static byte[] getGetData(URL url)
     {
-        return getGetData(url.getFile(), url.getHost(), url.getPort());
+        int port = url.getPort();
+        if (port > 0)
+            return getGetData(url.getFile(), url.getHost(), port);
+        else
+            return getGetData(url.getFile(), url.getHost());
     }
 
 }