version 1.162, 2008/10/17 07:16:35
|
version 1.164, 2008/11/25 19:27:27
|
|
|
HttpMethod httpMethod, | HttpMethod httpMethod, |
const AcceptLanguageList& acceptLanguages, | const AcceptLanguageList& acceptLanguages, |
const ContentLanguageList& contentLanguages, | const ContentLanguageList& contentLanguages, |
Uint32 contentLength) |
Uint32 contentLength, |
|
bool binaryRequest, |
|
bool binaryResponse) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
| |
|
|
{ | { |
out << STRLIT("POST /cimom HTTP/1.1\r\n"); | out << STRLIT("POST /cimom HTTP/1.1\r\n"); |
} | } |
out << STRLIT("HOST: ") << host << STRLIT("\r\n" |
out << STRLIT("HOST: ") << host << STRLIT("\r\n"); |
"Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
|
|
if (binaryRequest) |
|
{ |
|
// Tell the server that the payload is encoded in the OpenPegasus |
|
// binary protocol. |
|
out << STRLIT("Content-Type: application/x-openpegasus\r\n"); |
|
} |
|
else |
|
{ |
|
out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
|
} |
|
|
|
if (binaryResponse) |
|
{ |
|
// Tell the server that this client accepts the OpenPegasus binary |
|
// protocol. |
|
out << STRLIT("Accept: application/x-openpegasus\r\n"); |
|
} |
|
|
OUTPUT_CONTENTLENGTH(out, contentLength); | OUTPUT_CONTENTLENGTH(out, contentLength); |
if (acceptLanguages.size() > 0) | if (acceptLanguages.size() > 0) |
{ | { |
|
|
if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') | if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') |
#endif | #endif |
| |
|
if (!binaryResponse) |
|
{ |
|
// The binary protocol does not allow chunking. |
out << STRLIT("TE: chunked, trailers\r\n"); | out << STRLIT("TE: chunked, trailers\r\n"); |
|
} |
| |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
|
|
HttpMethod httpMethod, | HttpMethod httpMethod, |
const ContentLanguageList& contentLanguages, | const ContentLanguageList& contentLanguages, |
Uint32 contentLength, | Uint32 contentLength, |
Uint64 serverResponseTime) |
Uint64 serverResponseTime, |
|
bool binaryResponse) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
// Optimize the typical case for binary messages, circumventing the |
|
// more expensive logic below. |
|
if (binaryResponse && |
|
contentLength == 0 && |
|
httpMethod != HTTP_METHOD_M_POST && |
|
contentLanguages.size() == 0) |
|
{ |
|
static const char HEADERS[] = |
|
"HTTP/1.1 200 OK\r\n" |
|
"Content-Type: application/x-openpegasus\r\n" |
|
"content-length: 0000000000\r\n" |
|
"CIMOperation: MethodResponse\r\n" |
|
"\r\n"; |
|
|
|
// The HTTP processor fills in the content-length value later. |
|
// It searches for a field matching "content-length" (so the first |
|
// character must be lower case). |
|
out.append(HEADERS, sizeof(HEADERS) - 1); |
|
return; |
|
} |
|
|
out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"); | out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"); |
| |
#ifndef PEGASUS_DISABLE_PERFINST | #ifndef PEGASUS_DISABLE_PERFINST |
|
|
} | } |
#endif | #endif |
| |
|
if (binaryResponse) |
|
{ |
|
// According to MIME RFC, the "x-" prefix should be used for all |
|
// non-registered values. |
|
out << STRLIT("Content-Type: application/x-openpegasus\r\n"); |
|
} |
|
else |
|
{ |
out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); | out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
|
} |
|
|
OUTPUT_CONTENTLENGTH(out, contentLength); | OUTPUT_CONTENTLENGTH(out, contentLength); |
| |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
|
|
} | } |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
|
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
|
|
out << STRLIT("Ext:\r\n" | out << STRLIT("Ext:\r\n" |
"Cache-Control: no-cache\r\n" | "Cache-Control: no-cache\r\n" |
"Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="); | "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="); |
|
|
Buffer& out, | Buffer& out, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
Tracer::traceCIMException(TRC_XML_WRITER, Tracer::LEVEL2, cimException); |
Tracer::traceCIMException(TRC_XML, Tracer::LEVEL2, cimException); |
| |
out << STRLIT("<ERROR CODE=\"") << Uint32(cimException.getCode()); | out << STRLIT("<ERROR CODE=\"") << Uint32(cimException.getCode()); |
out.append('"'); | out.append('"'); |
|
|
HttpMethod httpMethod, | HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
const AcceptLanguageList& httpAcceptLanguages, | const AcceptLanguageList& httpAcceptLanguages, |
const ContentLanguageList& httpContentLanguages) |
const ContentLanguageList& httpContentLanguages, |
|
bool binaryResponse) |
{ | { |
Buffer out; | Buffer out; |
Buffer tmp; | Buffer tmp; |
|
|
httpMethod, | httpMethod, |
httpAcceptLanguages, | httpAcceptLanguages, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
out.size(), |
|
false, |
|
binaryResponse); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
tmp, | tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); |
out.size(), |
|
false); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
const String& authenticationHeader, | const String& authenticationHeader, |
const AcceptLanguageList& httpAcceptLanguages, | const AcceptLanguageList& httpAcceptLanguages, |
const ContentLanguageList& httpContentLanguages, | const ContentLanguageList& httpContentLanguages, |
const Buffer& body) |
const Buffer& body, |
|
bool binaryResponse) |
{ | { |
Buffer out; | Buffer out; |
Buffer tmp; | Buffer tmp; |
|
|
httpMethod, | httpMethod, |
httpAcceptLanguages, | httpAcceptLanguages, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
out.size(), |
|
false, |
|
binaryResponse); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
appendMethodResponseHeader(tmp, | appendMethodResponseHeader(tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); |
out.size(), false); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |