getting chunked response from the server

hi all,

i'm working on a issue in which when my http client recieves chunked response, it fails while writing the data in the internal process, i want to simulate it and for this i need to run a server which should respond with a chunked response so that i can see what's going wrong in my client part.

i know how to bring up a simple server listening on a port which accepts a client request, but no clues about the above mentioned scenario :(

please provide me some pointers for the above mentioned scenario, about what should i do,

tht's what i'm doing currently, a simple server,

package serverClientFundas;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.net.ServerSocket;

import java.net.Socket;

public class MyServer {

private static final int PORT_NUM = 43548;

public static void main(String[] args) {

ServerSocket serverSocket = null;

Socket clientSocket = null;

PrintWriter out = null;

BufferedReader in = null;

String str = null;

try{

serverSocket = new ServerSocket(PORT_NUM);

clientSocket = serverSocket.accept();

out = new PrintWriter(clientSocket.getOutputStream(),true);

in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

while((str = in.readLine()) != null && !str.equalsIgnoreCase("")){

System.out.println("got request from client: ["+str+"]");

out.println("response from server for input ["+str+"]");

}

}catch(IOException ioe){

System.err.println("server port not available: "+PORT_NUM);

}finally{

try{

if(in != null) in.close();

if(out != null) out.close();

if(clientSocket != null) clientSocket.close();

if(serverSocket != null) serverSocket.close();

}catch(IOException ioe){

System.err.println("error while closing server resources: ["+ioe.getMessage()+"]");

}

}

}

}

please tell me how to reply with a chunked te on top of this.

Message was edited by:

gaurav_abbi

[2198 byte] By [gaurav_abbia] at [2007-11-27 9:11:50]
# 1
Surely you'd be better off using an existing Web server that can already do that, so you can concentrate on the client?
ejpa at 2007-7-12 21:57:45 > top of Java-index,Core,Core APIs...
# 2

hi ejp,

actually the scenario is that in the product on which i'm currently working, we don't use any existing web server, the http client and server functionality is fully built in there, so in the issue, the in built client is getting the chunked response from an outside server and there its getting failed,

i understand what you are saying, but i'm somewhat new to the http functionality, so if u can give me some pointers like some tutorila knid of thing where i can do this.

i've idea about writing a simple response kind of scenario for post, get etc.

but how i can modify the response features, that i don't know..

:(

gaurav_abbia at 2007-7-12 21:57:45 > top of Java-index,Core,Core APIs...
# 3

There are several million Web servers on the Internet that do chunked response encoding that you can use for testing, and dozens of existing free implementations you can choose from if you have to implement the functionality.

Writing your own for this or any other purpose is a complete waste of time IMO.

ejpa at 2007-7-12 21:57:45 > top of Java-index,Core,Core APIs...