public Hashtable OnGetSnapshot(Hashtable keysvals) { Hashtable reply = new Hashtable(); string reqtag; string snapObj = (string)keysvals["region"]; if (string.IsNullOrWhiteSpace(snapObj)) { reqtag = GetClientString(keysvals); } else { reqtag = snapObj + GetClientString(keysvals); } if (!string.IsNullOrWhiteSpace(reqtag)) { if (throotleGen.Contains(reqtag)) { reply["str_response_string"] = "Please try your request again later"; reply["int_response_code"] = 503; reply["content_type"] = "text/plain"; m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later"); return(reply); } throotleGen.AddOrUpdate(reqtag, 0, 60); } if (string.IsNullOrWhiteSpace(snapObj)) { m_log.DebugFormat("[DATASNAPSHOT] Received collection request for all"); } else { m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj); } XmlDocument response = m_externalData.GetSnapshot(snapObj); if (response == null) { reply["str_response_string"] = "Please try your request again later"; reply["int_response_code"] = 503; reply["content_type"] = "text/plain"; m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later"); return(reply); } reply["str_response_string"] = response.OuterXml; reply["int_response_code"] = 200; reply["content_type"] = "text/xml"; return(reply); }
public void OnGetSnapshot(IOSHttpRequest req, IOSHttpResponse resp) { Hashtable reply = new Hashtable(); string reqtag; if (req.QueryAsDictionary.TryGetValue("region", out string snapObj) && !string.IsNullOrWhiteSpace(snapObj)) { reqtag = snapObj + req.RemoteIPEndPoint.Address.ToString(); } else { reqtag = req.RemoteIPEndPoint.Address.ToString(); } if (!string.IsNullOrWhiteSpace(reqtag)) { if (throotleGen.Contains(reqtag)) { resp.StatusCode = (int)HttpStatusCode.ServiceUnavailable; resp.StatusDescription = "Please try again later"; resp.ContentType = "text/plain"; m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later"); return; } throotleGen.AddOrUpdate(reqtag, 0, 60); } if (string.IsNullOrWhiteSpace(snapObj)) { m_log.DebugFormat("[DATASNAPSHOT] Received collection request for all"); } else { m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj); } XmlDocument response = m_externalData.GetSnapshot(snapObj); if (response == null) { resp.StatusCode = (int)HttpStatusCode.ServiceUnavailable; resp.ContentType = "text/plain"; m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later"); return; } resp.RawBuffer = Util.UTF8NBGetbytes(response.OuterXml); resp.ContentType = "text/xml"; resp.StatusCode = (int)HttpStatusCode.OK; }
public Hashtable OnGetSnapshot(Hashtable keysvals) { m_log.Debug("[DATASNAPSHOT] Received collection request"); Hashtable reply = new Hashtable(); int statuscode = 200; string snapObj = (string)keysvals["region"]; XmlDocument response = m_externalData.GetSnapshot(snapObj); reply["str_response_string"] = response.OuterXml; reply["int_response_code"] = statuscode; reply["content_type"] = "text/xml"; return(reply); }