/// <summary> /// Converts request into JSONDataMap /// </summary> protected JSONDataMap GetRequestAsJSONDataMap(WorkContext work) { if (!work.Request.HasEntityBody) { return(work.MatchedVars); } JSONDataMap result = null; var ctp = work.Request.ContentType; //Multipart if (ctp.IndexOf(ContentType.FORM_MULTIPART_ENCODED) >= 0) { result = MultiPartContent.ToJSONDataMap(work.Request.InputStream, ctp, work.Request.ContentEncoding); } else //Form URL encoded if (ctp.IndexOf(ContentType.FORM_URL_ENCODED) >= 0) { result = JSONDataMap.FromURLEncodedStream(new NFX.IO.NonClosingStreamWrap(work.Request.InputStream), work.Request.ContentEncoding); } else//JSON if (ctp.IndexOf(ContentType.JSON) >= 0) { result = JSONReader.DeserializeDataObject(new NFX.IO.NonClosingStreamWrap(work.Request.InputStream), work.Request.ContentEncoding) as JSONDataMap; } return(result == null ? work.MatchedVars : result.Append(work.MatchedVars)); }
/// <summary> /// Converts request body and MatchedVars into a single JSONDataMap. Users should call WholeRequestAsJSONDataMap.get() as it caches the result /// </summary> protected virtual JSONDataMap GetWholeRequestAsJSONDataMap() { var body = this.RequestBodyAsJSONDataMap; if (body == null) { return(MatchedVars); } var result = new JSONDataMap(false); result.Append(MatchedVars) .Append(body); return(result); }
/// <summary> /// Converts request body and MatchedVars into a single JSONDataMap. Users should call WholeRequestAsJSONDataMap.get() as it caches the result /// </summary> protected virtual JSONDataMap GetWholeRequestAsJSONDataMap() { var body = this.RequestBodyAsJSONDataMap; if (body==null) return MatchedVars; var result = new JSONDataMap(false); result.Append(MatchedVars) .Append(body); return result; }