Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
content_type in Client() post doesn't correctly encode
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christopher Hartfield  
View profile  
 More options Oct 14 2012, 1:48 am
From: Christopher Hartfield <ch...@mxmtech.net>
Date: Sat, 13 Oct 2012 22:48:55 -0700 (PDT)
Local: Sun, Oct 14 2012 1:48 am
Subject: content_type in Client() post doesn't correctly encode

I think I may have a bug in the client test class in the post method.
 Normally you can call:
    url_data = {'something': 'something'}
    response = c.post(ip, url_data, content_type='application/xml')

When I do this I get a 401 response and this data:
Content-Type: text/html; charset=utf-8

That's it. I don't get any actual data. If I remove the content_type
argument the problem goes away (but I have the default content type which I
don't want

I have come across this problem because I am testing an api and it requires
the content-type to be application/xml.

How do I specify content_type correctly in Django's testing client with
post data?  


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Keith-Magee  
View profile  
 More options Oct 14 2012, 7:18 pm
From: Russell Keith-Magee <russ...@keith-magee.com>
Date: Mon, 15 Oct 2012 07:17:12 +0800
Local: Sun, Oct 14 2012 7:17 pm
Subject: Re: content_type in Client() post doesn't correctly encode
On Sun, Oct 14, 2012 at 1:48 PM, Christopher Hartfield

The problem isn't the content type definition -- it's what your own
code is doing with the request.

A 401 response indicates that your own render() line isn't being
executed -- you're being bounced for a failed authentication. For some
reason, the client request isn't providing the expected authentication
credentials (either the HTTP_AUTHORIZATION header if you're using HTTP
Basic auth, or the session if you're using a login-based auth, or
possibly something else), and as a result, the client request is being
rejected.

I'm a little confused as to why dropping the content type argument
would alter the outcome, but this must be something to do with your
own code. Django itself doesn't have any 401 (to the extent that there
isn't even a 401 response type defined by default), so the code
raising the 401 isn't anything on Django's side.

Yours,
Russ Magee %-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »