Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
665 views
in Technique[技术] by (71.8m points)

curl - Django returning HTTP 301?

I have a django view that returns HTTP 301 on a curl request:

grapefruit:~ pete$ curl -I http://someurl
HTTP/1.1 301 MOVED PERMANENTLY
Date: Fri, 16 Oct 2009 19:01:08 GMT
Server: Apache/2.2.9 (Win32) mod_wsgi/2.5 Python/2.6.2 PHP/5.2.6
Location: http://someurl
Content-Type: text/html; charset=utf-8

I can't get the page's content from curl. However, if I visit the page with a browser, I see the content as expected.

Any ideas?

Thanks, Pete

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are probably requesting the URL without a trailing slash, and have APPEND_SLASH set to True (the default) in settings.py, so Django is redirecting to the URL including a slash.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...