http 1.1 determined connectors controlling sockets java


let's contend i have java way creates an http ask server controlling http 1.1 doesn't tie connection. i request, review information returned quarrel tide i have organization socket. however, on origination second request, i response server (or there's problem tide - doesn't yield any some-more input). i requests method (request, request, read) works fine, nonetheless (request, read, request, read) doesn't.



could someone broadcast understanding onto since competence happening? (code snippets follow). matter i do, second review loop's isr_reader.read() wholly ever advantage -1.



try{
tie = new socket("someserver", port);
con_out = connection.getoutputstream();
con_in = connection.getinputstream();
printwriter out_writer = new printwriter(con_out, false);
out_writer.print("get http://somesite http/1.1\r\n");
out_writer.print("host: thehost\r\n");
//out_writer.print("content-length: 0\r\n");
out_writer.print("\r\n");
out_writer.flush();

// interpreting information impression stream, competence need adjust byte organization here.
inputstreamreader isr_reader = new inputstreamreader(con_in);
char[] streambuf = new char[8192];
int amountread;
stringbuilder receiveddata = new stringbuilder();
while((amountread = isr_reader.read(streambuf)) > 0){
receiveddata.append(streambuf, 0, amountread);
}

// response processed here.

if(connection != zero && !connection.isclosed()){
//system.out.println("connection still open...");

out_writer.print("get http://somesite2\r\n");
out_writer.print("host: somehost\r\n");
out_writer.print("connection: close\r\n");
out_writer.print("\r\n");
out_writer.flush();

streambuf = new char[8192];
amountread = 0;
receiveddata.setlength(0);
while((amountread = isr_reader.read(streambuf)) > 0 || amountread < 1){
(amountread > 0)
receiveddata.append(streambuf, 0, amountread);
}
}
// slight response here
}


responses questions:
yes, i'm receiving chunked responses server.
i'm controlling tender sockets since an outmost restriction.



apologies disaster formula - i rewriting memory seem have introduced few bugs.



so settle i have presumably (request, request, read) let server tie tide once i strike end, or, i (request, read, request, read) stop before i strike finish tide stream isn't closed.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members