Re: Post request and encoding

2020-11-03 Thread Hernán De Angelis
I see. Should be "encoding". Thanks. /H. On 2020-11-03 19:30, Dieter Maurer wrote: Hernán De Angelis wrote at 2020-11-2 10:06 +0100: ... My request has the form: header = {'Content-type':'application/xml', 'charset':'utf-8'} Not your problem (which you have already resolved) but: `charset` i

Re: Post request and encoding

2020-11-03 Thread Dieter Maurer
Hernán De Angelis wrote at 2020-11-2 10:06 +0100: > ... >My request has the form: > >header = {'Content-type':'application/xml', 'charset':'utf-8'} Not your problem (which you have already resolved) but: `charset` is not an individual header but a parameter for the `Content-Type` header. For `xml`

Re: Post request and encoding

2020-11-02 Thread Grant Edwards
On 2020-11-02, Ethan Furman wrote: > On 11/2/20 9:32 AM, Karsten Hilbert wrote: > >> because .encode() does not operate in-place. > > Yeah, none of the string operations do, and it's embarrassing how > many times that still bites me. :-/ I've been writing Python for a little over 20 years. In an

Re: Post request and encoding

2020-11-02 Thread Variable Starlight
Thanks, I now learned the lesson. 👍 Den mån 2 nov. 2020 18:58Ethan Furman skrev: > On 11/2/20 9:32 AM, Karsten Hilbert wrote: > > > because .encode() does not operate in-place. > > Yeah, none of the string operations do, and it's embarrassing how many > times that still bites me. :-/ > > -- > ~

Re: Post request and encoding

2020-11-02 Thread Variable Starlight
No worries ☺ Den mån 2 nov. 2020 19:05Karsten Hilbert skrev: > On Mon, Nov 02, 2020 at 06:43:20PM +0100, Hernán De Angelis wrote: > > > I see, my mistake was (tacitly) assuming that encode() could work in > place. > > > > Now I see that it should work in a previous line as you wrote. > > > > Tha

Re: Post request and encoding

2020-11-02 Thread Karsten Hilbert
On Mon, Nov 02, 2020 at 06:43:20PM +0100, Hernán De Angelis wrote: > I see, my mistake was (tacitly) assuming that encode() could work in place. > > Now I see that it should work in a previous line as you wrote. > > Thank you! Sure, and excuse my perhaps slightly terse tone in that earlier mail .

Re: Post request and encoding

2020-11-02 Thread Ethan Furman
On 11/2/20 9:32 AM, Karsten Hilbert wrote: because .encode() does not operate in-place. Yeah, none of the string operations do, and it's embarrassing how many times that still bites me. :-/ -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Post request and encoding

2020-11-02 Thread Hernán De Angelis
I see, my mistake was (tacitly) assuming that encode() could work in place. Now I see that it should work in a previous line as you wrote. Thank you! /H. On 2020-11-02 18:32, Karsten Hilbert wrote: On Mon, Nov 02, 2020 at 06:21:15PM +0100, Hernán De Angelis wrote: For the record: Just repl

Re: Post request and encoding

2020-11-02 Thread Karsten Hilbert
On Mon, Nov 02, 2020 at 06:21:15PM +0100, Hernán De Angelis wrote: For the record: > Just reply to myself and whoever might find this useful. > > encode() must be done within the request call: Nope (but it can, as you showed). > header = {'Content-type':'application/xml', 'charset':'UTF-8'} > r

Re: Post request and encoding

2020-11-02 Thread Chris Angelico
On Tue, Nov 3, 2020 at 4:22 AM Hernán De Angelis wrote: > > Just reply to myself and whoever might find this useful. > > encode() must be done within the request call: > > header = {'Content-type':'application/xml', 'charset':'UTF-8'} > response = requests.post(server, data=request.encode('utf-8')

Re: Post request and encoding

2020-11-02 Thread Hernán De Angelis
Just reply to myself and whoever might find this useful. encode() must be done within the request call: header = {'Content-type':'application/xml', 'charset':'UTF-8'} response = requests.post(server, data=request.encode('utf-8'), headers=header) not in a previous separate line as I did. Now

Post request and encoding

2020-11-02 Thread Hernán De Angelis
Hi everyone, I am writing a program that sends a post request to a server. The post request may include keywords with Swedish characters (åöä). I noticed that requests that include strings without those characters return a useful expected response. On the other hand, posts including those ch