ValidateAndEmitRequest method
Validates request parameters, and emits the request to the server.
The request.
Implementation
Future<IEwsHttpWebResponse> ValidateAndEmitRequest(
OutParam<IEwsHttpWebRequest> requestOut,
) async {
Validate();
IEwsHttpWebRequest request = await BuildEwsHttpWebRequest();
requestOut.param = request;
if (Service.SendClientLatencies) {
String? clientStatisticsToAdd;
if (_clientStatisticsCache.isNotEmpty) {
clientStatisticsToAdd = _clientStatisticsCache.removeAt(0);
}
if (!StringUtils.IsNullOrEmpty(clientStatisticsToAdd)) {
final existing = request.Headers[_ClientStatisticsRequestHeader];
if (existing != null) {
request.Headers[_ClientStatisticsRequestHeader] =
existing + clientStatisticsToAdd!;
} else {
request.Headers.Add(
_ClientStatisticsRequestHeader,
clientStatisticsToAdd!,
);
}
}
}
DateTime startTime = DateTime.now().toUtc();
IEwsHttpWebResponse? response;
try {
response = await GetEwsHttpWebResponse(request);
} finally {
if (Service.SendClientLatencies) {
int clientSideLatency = DateTime.now()
.toUtc()
.difference(startTime)
.inMilliseconds;
String requestId = "";
String soapAction = runtimeType.toString().replaceAll("Request", "");
if (response != null) {
final headers = response.Headers;
for (String requestIdHeader in _RequestIdResponseHeaders) {
String? requestIdValue = headers[requestIdHeader];
if (!StringUtils.IsNullOrEmpty(requestIdValue)) {
requestId = requestIdValue!;
break;
}
}
}
StringBuffer sb = StringBuffer();
sb.write("MessageId=");
sb.write(requestId);
sb.write(",ResponseTime=");
sb.write(clientSideLatency);
sb.write(",SoapAction=");
sb.write(soapAction);
sb.write(";");
_clientStatisticsCache.add(sb.toString());
}
}
return response;
}