1
我有NodeJs天藍色的函數與Http觸發器。我正在使用POST方法並將主體發送到天藍色的函數。由於身體很大,所以使用gzip壓縮。Azure函數壓縮POST正文
我在azure函數中獲取請求,內容編碼頭是'gzip'。我試圖的NodeJS
zlib.gunzip(req.body,...)
使用,它引發了錯誤
Error: incorrect header check
我有NodeJs天藍色的函數與Http觸發器。我正在使用POST方法並將主體發送到天藍色的函數。由於身體很大,所以使用gzip壓縮。Azure函數壓縮POST正文
我在azure函數中獲取請求,內容編碼頭是'gzip'。我試圖的NodeJS
zlib.gunzip(req.body,...)
使用,它引發了錯誤
Error: incorrect header check
對於JavaScript功能,streaming is not supported和功能運行時提供請求體,而不是請求對象。對於C#函數沒有特別的處理,所以你可以嘗試使用C#函數。
這是一個C#函數,它解壓縮gzip請求主體供您參考。
using System.Net;
using System.IO.Compression;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
var inputStream = await req.Content.ReadAsStreamAsync();
string decompressedReqBody = string.Empty;
using (GZipStream decompressionStream = new GZipStream(inputStream, CompressionMode.Decompress))
{
using (StreamReader sr = new StreamReader(decompressionStream))
{
decompressedReqBody = sr.ReadToEnd();
log.Info(decompressedReqBody);
}
}
return req.CreateResponse(HttpStatusCode.OK, decompressedReqBody);
}