首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django Rest框架在本地主机的PATCHing中运行良好,但在同源性环境中失败

Django Rest框架在本地主机的PATCHing中运行良好,但在同源性环境中失败
EN

Stack Overflow用户
提问于 2017-07-27 19:25:02
回答 1查看 170关注 0票数 1

我刚刚在同源环境中部署了Django/Python应用程序。应用程序使用Django Rest框架实现REST

现在,我正在测试同源环境,并且对我想要做的部分更新的资源有一个小问题。但是,localhost中的测试应用程序运行良好。

Localhost: --我使用httpie来使用httpie资源。下面的命令向本地主机中的对象experiment发送一个修补程序:

代码语言:javascript
复制
http -a lab1:'nep-lab1' PATCH  http://127.0.0.1:8000/api/experiments/11/ status='to_be_analysed'

没关系,补丁做得很成功。

homolog :在同系物环境中相同的命令失败。

代码语言:javascript
复制
http -a lab1:'nep-lab1' PATCH  http://myhomologenv.com.br/api/experiments/11/ status='to_be_analysed'

错误:

代码语言:javascript
复制
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==

{&quot;status&quot;: &quot;to_be_analysed&quot;}</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

有关使用的工具和包的更多信息:Localhost:

  • Sqlite3
  • 虚拟服务器
  • Debian 9

同态:

  • Postgres 9.4.6
  • Apache/2.4.10 (Debian)
  • Debian 8.3

双双:

  • Django==1.11.2
  • djangorestframework==3.6.3
  • coreapi==2.3.1
EN

回答 1

Stack Overflow用户

发布于 2017-07-28 09:55:28

如响应所述,请与您的系统管理员联系。这个响应是从Squid生成的,所以它甚至没有到达Django项目。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45359388

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档