gpt4 book ai didi

python - Django Rest Framework 在本地主机的 PATCHing 中工作正常,但在同源环境中失败

转载 作者:行者123 更新时间:2023-11-29 13:48:00 26 4
gpt4 key购买 nike

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

现在我正在测试 homolog 环境,并且我想要进行部分更新的资源有点问题。但是在 localhost 中测试应用程序工作正常。

本地主机:我正在使用 httpie 来使用 API 资源。下面的命令将 PATCH 发送到本地主机中的对象 experiment:

http -a lab1:'nep-lab1' PATCH  http://127.0.0.1:8000/api/experiments/11/ status='to_be_analysed'

好了,PATCH制作成功

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

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==

{&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

有关使用的工具和包的更多信息:本地主机:

  • SQLite3
  • 虚拟服务器
  • Debian 9

同系物:

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

两者:

  • Django==1.11.2
  • djangorestframework==3.6.3
  • 核心API==2.3.1

最佳答案

如回复所述,请与您的系统管理员联系。此响应是从 Squid 生成的,因此它甚至不会到达您的 Django 项目。

关于python - Django Rest Framework 在本地主机的 PATCHing 中工作正常,但在同源环境中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45359388/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com