/// <summary> /// Parse the FSSHTTPB Bytes. /// </summary> /// <param name="FSSHTTPBbytes">The raw date contains FSSHTTPB message.</param> /// <param name="direction">The direction of the traffic.</param> /// <returns>The object parsed result</returns> public object ParseFSSHTTPBBytes(byte[] FSSHTTPBbytes, TrafficDirection direction) { object objectOut = null; byte[] emptyByte = new byte[0]; if (FSSHTTPBbytes == null || FSSHTTPBbytes.Length == 0) { return(null); } try { if (direction == TrafficDirection.In) { FsshttpbRequest FsshttpbReq = new FsshttpbRequest(); MemoryStream s = new MemoryStream(FSSHTTPBbytes); FsshttpbReq.Parse(s); objectOut = FsshttpbReq; } else { FsshttpbResponse FsshttpbRes = new FsshttpbResponse(); MemoryStream s = new MemoryStream(FSSHTTPBbytes); FsshttpbRes.Parse(s); objectOut = FsshttpbRes; } return(objectOut); } catch (Exception ex) { objectOut = ex.ToString(); return(objectOut); } }
/// <summary> /// Parse the HTTP payload to FSSHTTPB Request message. /// </summary> /// <param name="Requests">Array of Request that is part of a cell storage service request.</param> /// <param name="bytesFromHTTP">The raw data from HTTP layer.</param> public void TryParseFSSHTTPBRequestMessage(Request[] Requests, byte[] bytesFromHTTP) { if (Requests == null) { return; } byte[][] includeTexts = GetOctetsBinaryForXOP(bytesFromHTTP, true).ToArray(); int index = 0; foreach (Request req in Requests) { if (req.SubRequest != null && req.SubRequest.Length > 0) { foreach (SubRequestElementGenericType subreq in req.SubRequest) { if (subreq.SubRequestData != null) { if (subreq.SubRequestData.Text != null && subreq.SubRequestData.Text.Length > 0) { string textValue = subreq.SubRequestData.Text[0]; byte[] FSSHTTPBTextBytes = Convert.FromBase64String(textValue); if (!IsFSSHTTPBStart(FSSHTTPBTextBytes)) { return; } FsshttpbRequest Fsshttpbreq = (FsshttpbRequest)ParseFSSHTTPBBytes(FSSHTTPBTextBytes, TrafficDirection.In); subreq.SubRequestData.TextObject = Fsshttpbreq; FSSHTTPBBytes.Add(FSSHTTPBTextBytes); } if (subreq.SubRequestData.Include != null) { byte[] FSSHTTPBIncludeBytes = includeTexts[index++]; FsshttpbRequest Fsshttpbreq = (FsshttpbRequest)ParseFSSHTTPBBytes(FSSHTTPBIncludeBytes, TrafficDirection.In); subreq.SubRequestData.IncludeObject = Fsshttpbreq; FSSHTTPBBytes.Add(FSSHTTPBIncludeBytes); } } } } } }