472,780 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

Http server - Header problem

Hi,
I need to have a simple http server in one of my applications. It's
just for a little text data so i wanted to write my own.
So i have a listener on port 80 and i'm using async methods to receive
/ send data. My problem is, i found lots of sample web server
applications, all of them just calls socket.read method for 1-4kb data.
And parses the response for headers. Isn't it possible to receive
partial data from socket and break this method? I mean i do telnet
google.com:80 and write my request, server doesn't respond till i send
double newline.
What would you suggest? Just read once and go or check received data
for CRLF+CRLF?

Dec 14 '05 #1
1 1689
> What would you suggest? Just read once and go or check received data
for CRLF+CRLF?
No, there is no warranty that one read will bring you whole request.

you have to read until CRLF+CRLF is encountered. But it is not the end. this
approach will be suffice only for GET requests as there is no content
following...
if you issue POST requests then you have to obtain HTTP header ( ends with
double CRLF ) and then find field Content-Length and its value.

Then read until you receive Content-Length bytes of the info.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

<an*****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com... Hi,
I need to have a simple http server in one of my applications. It's
just for a little text data so i wanted to write my own.
So i have a listener on port 80 and i'm using async methods to receive
/ send data. My problem is, i found lots of sample web server
applications, all of them just calls socket.read method for 1-4kb data.
And parses the response for headers. Isn't it possible to receive
partial data from socket and break this method? I mean i do telnet
google.com:80 and write my request, server doesn't respond till i send
double newline.
What would you suggest? Just read once and go or check received data
for CRLF+CRLF?

Dec 14 '05 #2

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

Similar topics

2
by: Peter Gaunt | last post by:
I'm in the process of moving my site from one server to another (my old hosting company appears to have gone bust). On the old host and on my local Mac OS X machine I can send HTTP/1.1 response...
7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
1
by: John Smith | last post by:
I'm writing a service which accepts a POST call, updates a database and returns raw HTTP headers as specified below: HTTP/1.1 200 OK Content-type:text/plain Content-length:3 OK The code...
0
by: ramas | last post by:
Hi, I am new to PHP scripting and i am trying to connect to a soap server (as mentioned below) using the SOAP extension comesup with PHP. Now my requirement is to add my HTTP header fields along...
8
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has...
14
by: Chris Fink | last post by:
Looking for some general design recommendations on an authentication scheme for B2B transactions inbound via an HTTP Post Listener ASPX page that reads the binary stream from the request body. I...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
0
by: Nico Ploner | last post by:
Hello newsgroup, the following problem turns me mad. It would be great if anyone could have a look at it and maybe give me some hint. I have developed a server control, which should be...
7
by: shadowman | last post by:
Hello all: I have a web app that creates an image of a graph (as a png), based on user input of a combination of drop-down box items. I'm trying to add a function that allows the user to save...
3
by: Reporter | last post by:
Here is an example from the PHP Manual <?php if ((!isset($_SERVER)) || (1==1)) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Text to send...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.