version 1.112, 2004/10/17 20:39:18
|
version 1.113, 2004/10/25 18:26:02
|
|
|
// Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 | // Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 |
// Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase1 | // Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase1 |
// Willis White (whiwill@us.ibm.com) PEP 127 and 128 | // Willis White (whiwill@us.ibm.com) PEP 127 and 128 |
|
// Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
out << "Content-Language: " << contentLanguages << "\r\n"; | out << "Content-Language: " << contentLanguages << "\r\n"; |
} | } |
| |
|
#ifdef PEGASUS_DEBUG |
// backdoor environment variable to turn OFF client requesting transfer | // backdoor environment variable to turn OFF client requesting transfer |
// encoding. The default is on. to turn off, set this variable to zero. | // encoding. The default is on. to turn off, set this variable to zero. |
// This should be removed when stable. This should only be turned off in | // This should be removed when stable. This should only be turned off in |
// a debugging/testing environment. | // a debugging/testing environment. |
#ifdef PEGASUS_DEBUG |
|
static const char *clientTransferEncodingOff = | static const char *clientTransferEncodingOff = |
getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST"); | getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST"); |
if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') | if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') |
#endif | #endif |
|
|
out << "TE: chunked, trailers" << "\r\n"; | out << "TE: chunked, trailers" << "\r\n"; |
| |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
|
|
} | } |
| |
| |
//------------------------------------------------------------------------------ |
|
// |
|
// appendMethodResponseHeader() |
|
// |
|
// Build HTTP response header. |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
void XmlWriter::appendMethodResponseHeader( |
|
Array<Sint8>& out, |
|
HttpMethod httpMethod, |
|
const ContentLanguages & contentLanguages, |
|
Uint32 contentLength) |
|
{ |
|
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
|
|
|
out << "HTTP/1.1 " HTTP_STATUS_OK "\r\n"; |
|
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
|
OUTPUT_CONTENTLENGTH; |
|
|
|
if (contentLanguages.size() > 0) |
|
{ |
|
out << "Content-Language: " << contentLanguages << "\r\n"; |
|
} |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
|
out << "Ext:\r\n"; |
|
out << "Cache-Control: no-cache\r\n"; |
|
out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; |
|
out << nn <<"\r\n"; |
|
out << nn << "-CIMOperation: MethodResponse\r\n\r\n"; |
|
} |
|
else |
|
{ |
|
out << "CIMOperation: MethodResponse\r\n\r\n"; |
|
} |
|
} |
|
|
|
|
|
void XmlWriter::appendMethodResponseHeader( | void XmlWriter::appendMethodResponseHeader( |
Array<Sint8>& out, | Array<Sint8>& out, |
HttpMethod httpMethod, | HttpMethod httpMethod, |
|
|
Uint64 serverResponseTime) | Uint64 serverResponseTime) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
|
|
out << "HTTP/1.1 " HTTP_STATUS_OK "\r\n"; | out << "HTTP/1.1 " HTTP_STATUS_OK "\r\n"; |
STAT_SERVERTIME | STAT_SERVERTIME |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
|
|
// <IPARAMVALUE NAME="PropertyName"><VALUE>FreeSpace</VALUE></IPARAMVALUE> | // <IPARAMVALUE NAME="PropertyName"><VALUE>FreeSpace</VALUE></IPARAMVALUE> |
// | // |
// USE: Create parameter for getProperty operation | // USE: Create parameter for getProperty operation |
//----------------------------------------------------------- |
//========================================================== |
void XmlWriter::appendPropertyNameIParameter( | void XmlWriter::appendPropertyNameIParameter( |
Array<Sint8>& out, | Array<Sint8>& out, |
const CIMName& propertyName) | const CIMName& propertyName) |
|
|
return tmp; | return tmp; |
} | } |
| |
Array<Sint8> XmlWriter::formatSimpleMethodRspMessage( |
|
const CIMName& methodName, |
|
const String& messageId, |
|
HttpMethod httpMethod, |
|
const ContentLanguages & httpContentLanguages, |
|
const Array<Sint8>& body, |
|
Boolean isFirst, |
|
Boolean isLast) |
|
{ |
|
Array<Sint8> out; |
|
|
|
if (isFirst == true) |
|
{ |
|
// NOTE: temporarily put zero for content length. the http code |
|
// will later decide to fill in the length or remove it altogether |
|
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0); |
|
_appendMessageElementBegin(out, messageId); |
|
_appendSimpleRspElementBegin(out); |
|
_appendMethodResponseElementBegin(out, methodName); |
|
} |
|
|
|
if (body.size() != 0) |
|
{ |
|
out << body; |
|
} |
|
|
|
if (isLast == true) |
|
{ |
|
_appendMethodResponseElementEnd(out); |
|
_appendSimpleRspElementEnd(out); |
|
_appendMessageElementEnd(out); |
|
} |
|
|
|
return out; |
|
} |
|
|
|
|
|
//PEP 128 adding serverRsponseTime to header | //PEP 128 adding serverRsponseTime to header |
Array<Sint8> XmlWriter::formatSimpleMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleMethodRspMessage( |
const CIMName& methodName, | const CIMName& methodName, |
|
|
{ | { |
// NOTE: temporarily put zero for content length. the http code | // NOTE: temporarily put zero for content length. the http code |
// will later decide to fill in the length or remove it altogether | // will later decide to fill in the length or remove it altogether |
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0, serverResponseTime); |
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0, |
|
serverResponseTime); |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleRspElementBegin(out); | _appendSimpleRspElementBegin(out); |
_appendMethodResponseElementBegin(out, methodName); | _appendMethodResponseElementBegin(out, methodName); |
|
|
HttpMethod httpMethod, | HttpMethod httpMethod, |
const ContentLanguages & httpContentLanguages, | const ContentLanguages & httpContentLanguages, |
const Array<Sint8>& body, | const Array<Sint8>& body, |
Boolean isFirst, |
|
Boolean isLast) |
|
{ |
|
Array<Sint8> out; |
|
|
|
if (isFirst == true) |
|
{ |
|
// NOTE: temporarily put zero for content length. the http code |
|
// will later decide to fill in the length or remove it altogether |
|
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0); |
|
_appendMessageElementBegin(out, messageId); |
|
_appendSimpleRspElementBegin(out); |
|
_appendIMethodResponseElementBegin(out, iMethodName); |
|
if (body.size() != 0) |
|
_appendIReturnValueElementBegin(out); |
|
} |
|
|
|
if (body.size() != 0) |
|
{ |
|
out << body; |
|
} |
|
|
|
if (isLast == true) |
|
{ |
|
if (body.size() != 0) |
|
_appendIReturnValueElementEnd(out); |
|
_appendIMethodResponseElementEnd(out); |
|
_appendSimpleRspElementEnd(out); |
|
_appendMessageElementEnd(out); |
|
} |
|
|
|
return out; |
|
} |
|
|
|
|
|
|
|
Array<Sint8> XmlWriter::formatSimpleIMethodRspMessage( |
|
const CIMName& iMethodName, |
|
const String& messageId, |
|
HttpMethod httpMethod, |
|
const ContentLanguages & httpContentLanguages, |
|
const Array<Sint8>& body, |
|
Uint64 serverResponseTime, | Uint64 serverResponseTime, |
Boolean isFirst, | Boolean isFirst, |
Boolean isLast) | Boolean isLast) |
|
|
{ | { |
// NOTE: temporarily put zero for content length. the http code | // NOTE: temporarily put zero for content length. the http code |
// will later decide to fill in the length or remove it altogether | // will later decide to fill in the length or remove it altogether |
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0, serverResponseTime); |
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0, |
|
serverResponseTime); |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleRspElementBegin(out); | _appendSimpleRspElementBegin(out); |
_appendIMethodResponseElementBegin(out, iMethodName); | _appendIMethodResponseElementBegin(out, iMethodName); |
if (body.size() != 0) |
|
|
// output the start of the return tag. Test if there is response data by: |
|
// 1. there is data on the first chunk OR |
|
// 2. there is no data on the first chunk but isLast is false implying |
|
// there is more non-empty data to come. If all subsequent chunks |
|
// are empty, then this generates and empty response. |
|
if (body.size() != 0 || isLast == false) |
_appendIReturnValueElementBegin(out); | _appendIReturnValueElementBegin(out); |
} | } |
| |
|
|
| |
if (isLast == true) | if (isLast == true) |
{ | { |
if (body.size() != 0) |
if (body.size() != 0 || isFirst == false) |
_appendIReturnValueElementEnd(out); | _appendIReturnValueElementEnd(out); |
_appendIMethodResponseElementEnd(out); | _appendIMethodResponseElementEnd(out); |
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
|
|
out << "Content-Language: " << contentLanguages << "\r\n"; | out << "Content-Language: " << contentLanguages << "\r\n"; |
} | } |
| |
|
#ifdef PEGASUS_DEBUG |
// backdoor environment variable to turn OFF client requesting transfer | // backdoor environment variable to turn OFF client requesting transfer |
// encoding. The default is on. to turn off, set this variable to zero. | // encoding. The default is on. to turn off, set this variable to zero. |
// This should be removed when stable. This should only be turned off in | // This should be removed when stable. This should only be turned off in |
// a debugging/testing environment. | // a debugging/testing environment. |
#ifdef PEGASUS_DEBUG |
|
static const char *clientTransferEncodingOff = | static const char *clientTransferEncodingOff = |
getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST"); | getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST"); |
if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') | if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') |