0
我剛在同類環境中部署了我的Django/Python應用程序。該應用程序使用Django Rest Framework來實現REST
。Django Rest Framework在本地主機中的PATCHing中正常工作,但在同類環境中失敗
現在我正在測試同源環境,並且對我想要進行部分更新的資源有一點問題。但測試應用程序localhost
工作正常。
本地主機: 我使用httpie
來消費API資源。下面的命令發送一個補丁對象experiment
在本地主機:
http -a lab1:'nep-lab1' PATCH http://127.0.0.1:8000/api/experiments/11/ status='to_be_analysed'
,這一切的權利,該補丁是成功地進行。
同源物: 在同源環境中,同一命令失敗。
http -a lab1:'nep-lab1' PATCH http://myhomologenv.com.br/api/experiments/11/ status='to_be_analysed'
錯誤:
HTTP/1.0 400 Bad Request
Connection: close
Content-Length: 2065
Content-Type: text/html
Date: Thu, 27 Jul 2017 18:48:48 GMT
Server: squid/2.7.STABLE9
Via: 1.0 athena.ime.usp.br:3128 (squid/2.7.STABLE9)
X-Cache: MISS from athena.ime.usp.br
X-Cache-Lookup: NONE from athena.ime.usp.br:3128
X-Squid-Error: ERR_INVALID_REQ 0
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ERROR: The requested URL could not be retrieved</title>
<style type="text/css"><!--
%l
body
:lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; }
:lang(he) { direction: rtl; }
--></style>
</head><body id="ERR_INVALID_REQ">
<div id="titles">
<h1>ERROR</h1>
<h2>The requested URL could not be retrieved</h2>
</div>
<hr>
<div id="content">
<p><b>Invalid Request</b> error was encountered while trying to process the request:</p>
<blockquote id="data">
<pre>PATCH /api/experiments/12 HTTP/1.1
Host: portal-dev.numec.prp.usp.br
Connection: keep-alive
Accept-Encoding: gzip, deflate
Accept: application/json, */*
User-Agent: HTTPie/0.9.8
Content-Type: application/json
Content-Length: 28
Authorization: Basic bGFiMTpuZXAtbGFiMQ==
{"status": "to_be_analysed"}</pre>
</blockquote>
<p>Some possible problems are:</p>
<ul>
<li id="missing-method"><p>Missing or unknown request method.</p></li>
<li id="missing-url"><p>Missing URL.</p></li>
<li id="missing-protocol"><p>Missing HTTP Identifier (HTTP/1.0).</p></li>
<li><p>Request is too large.</p></li>
<li><p>Content-Length missing for POST or PUT requests.</p></li>
<li><p>Illegal character in hostname; underscores are not allowed.</p></li>
<li><p>HTTP/1.1 <q>Expect:</q> feature is being asked from an HTTP/1.0 software.</p></li>
</ul>
<p>Your cache administrator is <a href="mailto:webmaster">webmaster</a>.</p>
<br>
</div>
<script language="javascript">
if ('[unknown method]' != '[unknown method]') document.getElementById('missing-method').style.display = 'none';
if ('[no URL]' != '[no URL]') document.getElementById('missing-url').style.display = 'none';
if ('[unkown protocol]' != '[unknown protocol]') document.getElementById('missing-protocol').style.display = 'none';
</script>
<hr>
<div id="footer">
<p>Generated Thu, 27 Jul 2017 18:48:48 GMT by athena.ime.usp.br (squid/2.7.STABLE9)</p>
<!-- ERR_INVALID_REQ -->
</div>
</body></html>
我使用DefaultRouter
使對象url
的。
更多的工具和包裝: 本地主機:
- SQLITE3
- 虛擬服務器
- Debian的9
同源:
-
級
- 的Postgres 9.4.6
- 阿帕奇/ 2.4.10(Debian的)
- 的Debian 8.3
這兩種:
- Django的== 1.11.2
- djangorestframework = = 3.6.3
- coreapi == 2.3.1