Found it. Previous WWW::Mechanize solution works OK because forms, there, are encoded wholesale, each and every name and value, regardless. See 455-457.

With new Net::Async::HTTP code, I was trying to be smart, only encoding those text values which obviously require to be encoded. However, another value, a string, simple uid in hexadecimal, sneaked in, which happens to be utf8::upgraded. Then URI module (used by HTTP::Request::Common) produces the whole url-encoded form data in utf-8, as I understand. I don't know if it's expected and documented behaviour, but it's not what server, processing my forms, understands. So solution is to always loop through and encode everything, as in 455-457 lines mentioned.

use strict; use warnings; use utf8; use feature 'say'; use URI; use Encode 'encode'; use charnames 'cyrillic'; my $uri = URI-> new( 'http:' ); my $ascii_uid_str = 'abc'; # whatever ascii my $high_ascii_octets = encode( 'koi8-r', qq(\N{zhe})); # = chr 214; # (same as above) # whatever, too, but high-ascii $uri-> query_form( $ascii_uid_str, $high_ascii_octets ); say $uri-> query; utf8::upgrade( $ascii_uid_str ); # oops, unexpected $uri-> query_form( $ascii_uid_str, $high_ascii_octets ); say $uri-> query; __END__ abc=%D6 abc=%C3%96

In reply to Re: How to set charset when POSTing? by vr
in thread How to set charset when POSTing? by vr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.