LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-26-2009, 04:36 PM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
Help with HTTP protocol


Hi,

I am writing a small http proxy/tunnel and I am having trouble with knowing when there is data to be received on the socket.

I have tried to determine the amount of data to be received by looking after the "content-length" field in the http header but sometimes the server doesn't send one.

I am also having a lot of troubles with the chunked packages.

Anyone here who knows his way around HTTP and can help me shed some light on this? All I need to know is how much data to receive. I really don't want to rely on timeouts while using my sockets cause that really slows things down to make it impossible to actually use the proxy.

The proxy is really simple, it doesn't do anything with the packages, just sends them back and forth.

Thanks,
 
Old 02-27-2009, 05:38 AM   #2
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 342

Rep: Reputation: 38
Hi

What language are you programming in?

Also, you may want to check out the NON-BLOCKING mode of your stream (open connection), that way, you can read from the stream, and if there is no data, the call returns immediately.
 
Old 02-27-2009, 09:01 AM   #3
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by x_terminat_or_3 View Post
Hi

What language are you programming in?

Also, you may want to check out the NON-BLOCKING mode of your stream (open connection), that way, you can read from the stream, and if there is no data, the call returns immediately.
I am using python and no, it does not. The call waits for a timeout if there is no data.
 
Old 02-27-2009, 09:08 AM   #4
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 342

Rep: Reputation: 38
Found with Google:

Quote:
In Python, you use socket.setblocking(0) to make it non-blocking
See http://www.amk.ca/python/howto/sockets/

Hope this helps.
 
Old 02-28-2009, 08:08 AM   #5
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by x_terminat_or_3 View Post
Found with Google:



See http://www.amk.ca/python/howto/sockets/

Hope this helps.
No, it does not. The problem is not the blocking part of the socket. The problem is that HTTP 1.1 uses persistent connections by default (unlike HTTP 1.0) and therefore I cannot rely on the function to return when there is no more data on the socket to be read.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kicstart installation using http protocol mokku Linux - Newbie 3 10-01-2007 12:09 AM
[C/C++] HTTP-Protocol; Getting the size of a webpage. quentusrex Programming 6 10-27-2004 08:29 AM
Using htts protocol in a http server nache Linux - Security 7 07-13-2004 09:44 AM
http protocol/programming advice... Scrag Programming 2 06-20-2004 10:00 PM
"socks5" -> "http" proxy protocol, or ssh tunnel to sock5 ? I'm beyond http p vmicho Linux - Networking 2 12-16-2003 05:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration