Home  |  About  | Last |  Submit  |  Contact
AllQuests.com



Previous Question:  gethostbyname wont work  Networking Device CommunicationNext Question:  Implementing TLVs  Networking Device Communication
Question Determining HTTP Header ( C Board Networking Device Communication )
Updated: 2008-08-12 08:32:58 (8)
Determining HTTP Header

Nowadays I want to make a local proxy using socket.

Btw, how we can determining whether the received buffer is a HTTP header / content file?

Answers: Determining HTTP Header ( C Board Networking Device Communication )
Determining HTTP Header

If you understand how HTTP works it would be very clear. Note that you'll actually need to understand HTTP in great depth to make a proxy server (at least one that follows the HTTP standards) -- see the RFC.

zacs7

Determining HTTP Header

Yeah, thank you zacs7.

Btw the structure of HTTP connection is:

Code:
Request header: header + "\r\n"
Response header: header + "\r\n" + content (if any)
Well, I discovered that internet/network programming is so interesting.
It's complex but standarized.

But I just get confused when different browser sends different thing of request.

For example:
From http:// username : password @ server
typed in address bar.

Firefox sent:
Code:
GET http://server/ HTTP/1.1
Host: http://server
Opera sent:
Code:
GET http://server/ HTTP/1.1
Host: http://server:80 (extra useful? port)
Authentication: Basic aaBBccDDee (plus this)
Also they act different when we are inputting https:// address.


Btw, they said C is for network programming. But where is the std* API for network?

Should I use WSA* API in Windows?

audinue

Determining HTTP Header

Sockets is the "standard" for TCP/IP network programming, which is the basis of the Internet. See Beej's Guide for a nice tutorial for programming sockets.

Yes, the WSA* stuff is Winsock, the Windows Sockets API. Here's how to do a basic Winsock app.

rags_to_riches

Determining HTTP Header

Wow, your reply is very-very help me rags_to_riches...

Thank you.

Btw I think "standard" is something like stdlib.h, stdio.h, time.h that provided portability and included in every C compilers ^_^ ...

Notes:
I found that Internet Explorer doesn't suport proxies for FTP protocols.

audinue

Determining HTTP Header

Quote:
Btw I think "standard" is something like stdlib.h, stdio.h, time.h that provided portability and included in every C compilers ^_^ ...
There is no support for network programming in the C standard library. On the other hand, sockets programming is at least a de facto standard.

laserlight

Determining HTTP Header

C and UNIX were developed together. BSD sockets was developed on BSD (I think) UNIX. Therefore, you can see how sockets and C go together.

robwhit

Determining HTTP Header

It's ok I think I will go search something like cygwin to make a portable local proxy...

Btw, guys, I have a problem about receiving and sending request andresponse header in my proxy...

Code:
client -> serverProxy -> clientProxy -> server -> clientProxy -> serverProxy -> client
1. A client sends a raw request header to the serverProxy(a socket).

2. The proxy translate them into web request header then send it to the server via clientProxy(a socket).

3. The clientProxy get the response header and the content. The proxy synchronizing it with serverProxy.

4. The serverProxy send the response header and the content to the browser.

...

My questions
In step 2, any tips for translating raw to web request header?
In step 4, do we need to do something with response header in step 4?

And ...
What is the advantages/disadvantages of blocking and non-blocking connection in socket?

audinue

Determining HTTP Header

Hey, I found a clear and simple Socket tutorial:
http://www.nullterminator.net/winsock.html

audinue

Previous Question:  gethostbyname wont work  C Board  Networking Device CommunicationNext Question:  Implementing TLVs  C Board  Networking Device Communication

- Source: Determining HTTP Header C Board Networking Device Communication
- Previous Question: gethostbyname wont work C Board Networking Device Communication
- Next Question: Implementing TLVs C Board Networking Device Communication