|
|||||||||||
|
DO NOT REPLY [Bug 7571] New: - DataInputStream readLong() Problem
From: <bugzilla(at)apache.org>
Date: Thu Mar 28 2002 - 07:19:02 EST
DataInputStream readLong() Problem
Summary: DataInputStream readLong() Problem
Product: Apache httpd-1.3
Version: 1.3.24
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: Content-type
AssignedTo: bugs@httpd.apache.org
ReportedBy: pauric.cregg@spectel.com
Configuration - Apache 1.3.24, AJP13, Tomcat 4.0.3 When doing a post request from an applet to a servlet via Apache, the DataInputStream.readLong() value does not appear to be read correctly. In order to test this I have created a testClient and testServlet the code for which is included below plus the output I received when I ran the tests. If I test against Tomcat directly everything works fine. If the request is routed via Apache first the values appear to be corrupted. Below is the output I receive from the test program. Does anybody have any idea why the example code below does not work on Apache ? >From what I understand it should work and appears to work fine when using
best regards
First Run on Tomcat
Starting service Tomcat-Standalone
Called Test Servlet doGet() Called Test Servlet doGet() Called Test Servlet doGet() Called Test Servlet doGet() Test Servlet doPost() Header ->content-type Value ->application/octet-stream Header ->user-agent Value ->Java1.3.1_01 Header ->host Value ->192.168.1.105:8080 Header ->accept Value ->text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Header ->connection Value ->keep-alive Header ->content-length Value ->16 Conference100 ID String 1234567890 Command500 Second run via Apache
Called Test Servlet doGet()
Header ->content-type Value ->application/octet-stream Header ->connection Value ->keep-alive Header ->accept Value ->text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Header ->host Value ->192.168.1.105 Header ->content-length Value ->16 Header ->user-agent Value ->Java1.3.1_01Conference100 ID String 1217855954 Command65780 TESTCLIENT import java.net.*; import java.io.*; import java.util.*;
public class TestClient extends Thread
public static void main(String args[]) {
try
{
String url
= "http://<localhost>/test/servlet/com.spectel.test.server.TestServlet"; System.out.println("Started Test Client");
URL u = new URL(url);
URLConnection x = u.openConnection();
HttpURLConnection urlCon = (HttpURLConnection)x;
System.out.println("URL for Test Client " + url);
String type = "POST";
urlCon.setRequestMethod(type);
urlCon.setDoOutput(true);
urlCon.setDoInput(true);
urlCon.setUseCaches(false);
urlCon.setDefaultUseCaches(false);
urlCon.setRequestProperty("Content-type","application/octet-
stream ");
System.out.println("Set up POST Request" + url); DataOutputStream out=new DataOutputStream(urlCon.getOutputStream());
out.writeInt(100);
out.writeLong(1234567890);
out.writeInt(500);
out.flush();
out.close();
System.out.println("Executed POST Request" + url);
HttpURLConnection htp = (HttpURLConnection)urlCon;
System.out.println("Response code is -> " + htp.getResponseCode());
}
catch(Exception e)
{
System.out.println("Post Connect Failed :" + e.toString());
}
} } TESTSERVLET import java.io.*; import java.util.*; import java.text.*; import java.net.URL; import java.net.MalformedURLException; import javax.servlet.*; import javax.servlet.http.*; public class TestServlet extends HttpServlet { public void init(ServletConfig config) throws ServletException { super.init(config); ServletContext sc = getServletContext(); } public void doPost(HttpServletRequest postReq, HttpServletResponse postRes) throws IOException, ServletException { System.out.println("Test Servlet doPost()"); Enumeration enum = postReq.getHeaderNames();
while(enum.hasMoreElements())
{
String name = (String)enum.nextElement();
String value = postReq.getHeader(name);
System.out.println("Header ->" + name + " Value ->" + value);
}
DataInputStream in = null;
in = new DataInputStream(postReq.getInputStream());
int ref = in.readInt();
System.out.println("Reference" + ref);
long uniqueID = in.readLong();
System.out.println("ID String " + uniqueID);
int command = in.readInt();
System.out.println("Command" + command);
}
public void doGet(HttpServletRequest postReq, HttpServletResponse postRes) throws IOException, ServletException {
System.out.println("Called Test Servlet doGet()");
}
System.exit(0);
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org For additional commands, e-mail: bugs-help@httpd.apache.org Received on Thu Mar 28 12:19:08 2002 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 16:43:02 EDT |
||||||||||
|
|||||||||||