Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Create proxy http

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 27-01-2010
Member
 
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
Quote:
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.
Reply With Quote
  #2  
Old 27-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,386
Re: Create proxy http

Hello,
Just check this part of the code
Quote:
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 ...)
Reply With Quote
  #3  
Old 27-01-2010
Member
 
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.
Reply With Quote
  #4  
Old 27-01-2010
Member
 
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?
Reply With Quote
  #5  
Old 27-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,842
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";
						
	}
Reply With Quote
  #6  
Old 27-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,386
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Create proxy http"
Thread Thread Starter Forum Replies Last Post
Not able to connect to local HTTP Server due to OfficeScan Proxy Glinda Networking & Security 8 23-08-2011 12:56 PM
iOS 4 Wifi Problems iPhone 3GS, HTTP Proxy...worked fine on 3.1.2/3.1.3 Hectorss Portable Devices 6 14-10-2010 05:58 PM
Cydia via http proxy? Saket Shukla Portable Devices 8 28-09-2010 11:37 PM
Not able to connect Assassins Creed 2 online via HTTP proxy Courtenay Video Games 4 13-03-2010 12:16 PM
Connect to HTTP with FQDN using proxy fragranz Networking & Security 4 02-02-2010 07:45 AM


All times are GMT +5.5. The time now is 12:54 PM.