Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Reading HTTP request using InputStream

Thread view: 
Ben - 16 Feb 2006 22:01 GMT
Hi,

I'm using Inputstream to read an HTTP request from my browser (i'm
actually making a proxy).
The code:
        InputStream in = new DataInputStream(socket.getInputStream());
        ArrayList<Integer> byteArray = new ArrayList<Integer>();
        int currByte=in.read();
        while (currByte!=-1){  // Reading byte until -1 is reached
            byteArray.add(new Integer(currByte));
            System.out.print((char)currByte);
            currByte = in.read();
        }
For some reason, instead of recognizing the end of the request and
returning -1 InputStream.read() blocks forever.

Am i doing something wrong??
Thanks,
Ben.
Finomosec - 16 Feb 2006 23:19 GMT
Ben schrieb:
> Hi,
>
[quoted text clipped - 15 lines]
> Thanks,
> Ben.

See Thread: "writing a proxy ..."
news.online.de comp.lang.java.programmer:631136

There is more advanced code for a proxy.

There may be a EOT or EOF signal, that indicates the end of the stream.

But anyway you should implement a timeout in case the browser aborts the
request, or the connection is lost before end of the request/answer.

Maybe its better to take an existing Java-Proxy and modify it to your needs.

Maybe this can be used (found it on a quick google search):
http://simile.mit.edu/httptracer/index.html
This looks like the main proxy-class:
http://simile.mit.edu/repository/httptracer/trunk/src/edu/mit/simile/tools/httpt
racer/Connection.java


Greetings Finomosec;


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.