Results 1 to 6 of 6

Thread: Create proxy http

  1. #1
    Join Date
    Dec 2009
    Posts
    204

    Create proxy http

    Hello,
    I am trying to write a http proxy in java using sockets. I get the header of the browser. Then I forward it to the web server. Then I get the header from the server and the message.
    Problem:
    The server does not send the message length ( "Content-Length:")
    How do I know where I must stop reading?
    I tried several methods
    buffer = null
    -tampon.equals ( "0"))
    This does not work all the time.
    is a string buffer (buffer = in.readLine ()).
    Last edited by Ash maker; 27-01-2010 at 09:29 AM.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,394

    Re: Create proxy http

    Hello,
    Just check this part of the code
    String buffer = "";
    while ( (buffer = in.readLine()) != null) { / / You put the line you just read into your buffer variable and you test it void.
    / / What you do.
    }
    After to know the type of file server you must return a Content-Type header (head has therefore also check the http rfc) which allows you to know (text, png, jpeg ...)

  3. #3
    Join Date
    Dec 2009
    Posts
    204

    Re: Create proxy http

    Hello,
    Thank you for your reply, My problem is rule: I have used the method read
    Code:
    (char [])!=- 1
    and it works well. I would look for the http rfc cache. Is there any other alternative for the doing the same. If there are any other methods then please help me.

  4. #4
    Join Date
    Dec 2009
    Posts
    178

    Re: Create proxy http

    Hello,
    Even I have the same problem with the program, I am also trying the same code on the http proxy. I am half done.
    It crashes in this statement:
    Code:
    while ((buffer = in.readLine ())! = null)
    What is the problem with my code, Is the socket is closed? Am I correct?

  5. #5
    Join Date
    Feb 2008
    Posts
    1,856

    Creating an http proxy code

    Hello,
    I still have the problem to retrieve the message from the server in the header if I do not have the message length. I tried the 2 methods but none of them worked. this is my code here.
    Code:
    while( true )
    	{
    	buff = fromServer.readLine();
    	if(buff == null) break;
    message + = buff +"\ r\ n";
    						
    	}

  6. #6
    Join Date
    Oct 2005
    Posts
    2,394

    Re: Create proxy http

    Hi,
    What feeds you use to retrieve the data? It seems that some flow block until there is no data. If I remember avalaible function () which returns you the number of bytes that can still be read, look in the javadoc it will help you, try using this method and then see if the code runs. If you have any problem then do post back.

Similar Threads

  1. Not able to connect to local HTTP Server due to OfficeScan Proxy
    By Glinda in forum Networking & Security
    Replies: 8
    Last Post: 23-08-2011, 12:56 PM
  2. Replies: 6
    Last Post: 14-10-2010, 05:58 PM
  3. Cydia via http proxy?
    By Saket Shukla in forum Portable Devices
    Replies: 8
    Last Post: 28-09-2010, 11:37 PM
  4. Replies: 4
    Last Post: 13-03-2010, 12:16 PM
  5. Connect to HTTP with FQDN using proxy
    By fragranz in forum Networking & Security
    Replies: 4
    Last Post: 02-02-2010, 07:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •