473,789 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

http response parser in c

Hello members,

I want to write a http response parser in c.

plz help me out...how should i proceed in writing the code... what
functions should i use....

Kind regards,
Sachin
Feb 25 '08 #1
5 6870
Sachin wrote:
Hello members,

I want to write a http response parser in c.

plz help me out...how should i proceed in writing the code... what
functions should i use....
That depends what type of parser you require. Google for htmltidy.

--
Ian Collins.
Feb 25 '08 #2
On Feb 25, 9:39*am, Sachin <svh...@gmail.c omwrote:
I want to write a http response parser in c.
The W3C gives a fairly comprehensive specification for the HTTP
protocol on its website. In general, you accept a command line that
starts with "GET", "HEAD", "PUT" and so on, usually followed by the
URL path (like "/~user/index.html" or something similar) then usually
followed by something like "HTTP/1.1" then a CR and LF. After that
you have sub-commands like: "Connection : Keep-Alive\r\n" or "Cookie:
<...>\r\n" or "Content-Encoding: <...>\r\n" or "User-Agent: <...>\r\n"
and so on to give more information about the command. Its then
followed by an additional CR, LF and then possible content parameters
(encoded according to earlier parameters; typically www-url-encoding
or MIME if its a form post of some kind).

I've never written a HTTP server, only the client. But I cannot
imagine that its really all that difficult. There must be available
source out there somewhere.
plz help me out...how should i proceed in writing the code... what
functions should i use....
For just the parser part, you don't need to go beyond string
comparisons. Regular expression parsers such as PCRE might help a
little bit, but I don't think that it makes a big difference.

If you want to do this in practice, I would recommend that you also
install Apache and Ethereal (both are available for the most relevant
operating systems.) That way you can observe the protocol response
for a real HTTP server.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
Feb 25 '08 #3
In article <62************ *@mid.individua l.net>,
Ian Collins <ia******@hotma il.comwrote:
>I want to write a http response parser in c.
>That depends what type of parser you require. Google for htmltidy.
He wants to parse HTTP responses, not the HTML that might be in
the body of the response. That is, this sort of stuff:

HTTP/1.1 200 OK
Date: Mon, 25 Feb 2008 22:06:32 GMT
Server: Apache/1.3.33 (Darwin)
Content-Location: index.html.en
Vary: negotiate,accep t-language,accept-charset

-- Richard

--
:wq
Feb 25 '08 #4
On Feb 26, 3:12*am, rich...@cogsci. ed.ac.uk (Richard Tobin) wrote:
In article <62geeeF22asj.. .@mid.individua l.net>,
Ian Collins *<ian-n...@hotmail.co mwrote:
I want to write a http response parser in c.
That depends what type of parser you require. *Google for htmltidy.

He wants to parse HTTP responses, not the HTML that might be in
the body of the response. *That is, this sort of stuff:

* HTTP/1.1 200 OK
* Date: Mon, 25 Feb 2008 22:06:32 GMT
* Server: Apache/1.3.33 (Darwin)
* Content-Location: index.html.en
* Vary: negotiate,accep t-language,accept-charset

-- Richard

--
:wq
u r right....i want to parse the above mentioned strings......ho w to
go about it???
Feb 26 '08 #5
Sachin wrote:
>
.... snip ...
>
u r right....i want to parse the above mentioned strings......ho w to
go about it???
Start by learning to spell common English words, such as 'you' and
'are'. Also the personal pronoun 'I'. Then consider how to
punctuate. A long series of dots is not a period.

After you do all that you will have reduced your annoyance level.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Feb 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5286
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o Modules/python.c gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o...
0
2644
by: Subodh | last post by:
I'm trying to make a HTTP request to a Web server. The Perl module is executed in mod_perl on Apache 1.3 The code : ---------------- my $r = shift; my $browser = LWP::UserAgent->new( ); $url = 'http://10.3.8.137/'; my $response = $browser->get($url); my $response_line = $response->status_line();
9
30325
by: Ricardo | last post by:
Hi. How should I pass a " (doble-quote) character to response.write() in order for it to be sent to the output ? Thanks in advance for the help.
2
1416
by: Peter Morris | last post by:
Hi, I'm just trying to learn ASP.NET C# programming from a book. I'm stuck on the chapter on HTTP modules. The example in the book shows a fragment to insert into web.config, plus a program that should be placed in the /bin directory. The book says this will insert a timestamp into the web page. Actually, all it does is show an error message in the page Parser Error Message: File or assembly name SimpleModules, or one of its...
4
26283
by: swl | last post by:
How do I consume xml and send back an xml response not using SOAP in an asp.net aspx page using vb.net?
1
4448
by: Tim Menninger | last post by:
When I use the XslTransform.Transform method to write to the HttpRequest.OutputStream The first byte of the output is always an invalid character, looks like an ascii zero or some other non-printable ascii char. The problem is that it messes up my display. Here is the code: .... Response.Write("<span>some text</span>"); XmlTextReader reader = new XmlTextReader(xslFile); XslTransform xsl = new XslTransform();
3
1965
by: msnews.microsoft.com | last post by:
Hello. I have this code in a project named ProductsHandler: First, a class called ProductsHandler.vb (this particular code is not important in this question, because the class is correct - it implements both IHttpHandler.ProcessRequest and IHttpHandler.IsReusable). Anyway, here it is: --------------------------------------------------------------------------------------- Imports System.Data.SqlClient Imports System.Web Imports...
1
8227
by: zort15 | last post by:
I'm trying to get the HTTP Response header out of a WebBrowser control so I can figure out what type of document it is, specifically RSS versus HTML. I tried using WebBrowser.DocumentType, but the return value of that seems dependent on your default program settings (as HTML documents show up as "Firefox Document" for me), and I also do not want to just assume that all "XML Document"s are RSS feeds. I also tried using the XML parser to...
0
2242
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): PERL5LIB=/Users/Ric/Library/Perl/ ls XML-Parser-2.34/ XML-Parser-2.34.tar
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9984
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.