Http.php 解檔頭有問題。

flimulus

您好,本人使用 Unity3d 內建的元件,直接將資料 Post 到 workerman JsonPrc Worker

其中使用到 Http.php 做檔頭解碼,有些問題回報。

Unity3d 用戶端傳送資料程式:

WWWForm postForm = new WWWForm();
postForm.AddField("class", "User");
postForm.AddField("method", "getInfoByUid");
postForm.AddField("param_array", SimpleJson.SimpleJson.SerializeObject(_param_array));

以下為伺服器端抓到的檔頭
//===========================================================================

POST / HTTP/1.1
User-Agent: UnityPlayer/4.6.2f1 (xxx://unity3d.com)
Host: 192.168.237.128:2015
Accept: _/_
Accept-Encoding: identity
Content-Length: 706
Content-Type: multipart/form-data; boundary="A4ntwtQ8QhmWpU0Ac4f4TasjhyG61At7XJXlCoMw"
X-Unity-Version: 4.6.2f1

--A4ntwtQ8QhmWpU0Ac4f4TasjhyG61At7XJXlCoMw
Content-Type: text/plain; charset="utf-8"
Content-disposition: form-data; name="class"

User
--A4ntwtQ8QhmWpU0Ac4f4TasjhyG61At7XJXlCoMw
Content-Type: text/plain; charset="utf-8"
Content-disposition: form-data; name="method"

getInfoByUid
--A4ntwtQ8QhmWpU0Ac4f4TasjhyG61At7XJXlCoMw
Content-Type: text/plain; charset="utf-8"
Content-disposition: form-data; name="param_array"

--A4ntwtQ8QhmWpU0Ac4f4TasjhyG61At7XJXlCoMw--

//==============================================================================
問題:
其中 boundary="A4ntwtQ8QhmWpU0Ac4f4TasjhyG61At7XJXlCoMw"
1.有加引號,http.php 解碼器只解未加引號

Content-disposition: 標記 與 http.php 解碼 Content-Disposition 大小寫不一致。
$boundary_value 並無 \r\n ,以下程式會將$boundary_value去掉末尾2碼有點危險
// 去掉末尾\r\n
$boundary_value = substr($boundary_value, 0, -2);

附上檔頭檔。請參考。
謝謝您。

2868 2 0
2个回答

flimulus

附檔

  • 暂无评论
walkor

非常感谢 flimulus 的反馈

这边会尽快fix

  • 暂无评论
年代过于久远,无法发表回答
🔝