Tuesday, August 31, 2004

HTTP v1.1 : I have added support for HTTP v1.1 to the HTTP server of CyberLink. I have added the many changes, and I have passed the existing test cases of CPPUnit and JUnit. I have to add the new test cases, but the following is the implementation for HEAD and CONTENT-RANGE request.
boolean HTTPSocket::post(HTTPResponse httpRes, byte content[], long contentOffset, long contentLength, boolean isOnlyHeader)

{
httpRes.setDate(Calendar.getInstance());
OutputStream out = getOutputStream();
try {
out.write(httpRes.getHeader().getBytes());
out.write(HTTP.CRLF.getBytes());
if (isOnlyHeader == true) {
out.flush();
return true;
}
out.write(content, (int)contentOffset, (int)contentLength);
out.flush();
}
catch (Exception e) {
//Debug.warning(e);
return false;
}
return true;
}

boolean HTTPRequest::post(HTTPResponse httpRes)
{
HTTPSocket httpSock = getSocket();
long offset = 0;
long length = httpRes.getContentLength();
if (hasContentRange() == true) {
long firstPos = getContentRangeFirstPosition();
long lastPos = getContentRangeLastPosition();
offset = firstPos;
length = lastPos - firstPos + 1;
}
httpSock.post(httpRes, offset, length, isHeadRequest());
//httpSock.close();
}

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?