Return-Path: X-Original-To: apmail-perl-embperl-archive@www.apache.org Delivered-To: apmail-perl-embperl-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1C49017513 for ; Thu, 2 Apr 2015 16:47:51 +0000 (UTC) Received: (qmail 20797 invoked by uid 500); 2 Apr 2015 16:47:50 -0000 Delivered-To: apmail-perl-embperl-archive@perl.apache.org Received: (qmail 20767 invoked by uid 500); 2 Apr 2015 16:47:50 -0000 Mailing-List: contact embperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list embperl@perl.apache.org Received: (qmail 20757 invoked by uid 99); 2 Apr 2015 16:47:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Apr 2015 16:47:50 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.81.96.145] (HELO app01.mss.la1.infostreet.net) (208.81.96.145) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Apr 2015 16:47:25 +0000 Received: (qmail 10763 invoked from network); 2 Apr 2015 16:44:22 -0000 Received: from unknown (HELO ?192.168.10.110?) (donl@mycopanet.com@24.199.7.226) by app01 with SMTP; 2 Apr 2015 16:44:21 -0000 Message-ID: <551D71E2.2070005@mycopanet.com> Date: Thu, 02 Apr 2015 09:44:18 -0700 From: Donavon User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Frank Wesemann CC: embperl@perl.apache.org Subject: Re: embperl and JSON References: <551980B3.9070205@mycopanet.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------010609020503060206050703" X-Virus-Checked: Checked by ClamAV on apache.org --------------010609020503060206050703 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hello and Thank You for the reply. From the embperl documentation: " (Embperl uses CGI.pm internally to process forms encoded with multipart/form-data.)" Does embperl convert "Content-Type: application/json" to "multipart/form-data"? or Does embperl also use CGI.pm to populate %fdat? In my script I am just using %fdat. I am not loading nor using CGI.pm. Any documentation that I have seen online refer to embperl and CGI.pm as separate, so unless I load CGI.pm or use "multipart/form-data" it should be a different issue. Am I missing something? Thank You, ~Donavon On 4/2/2015 4:44 AM, Frank Wesemann wrote: > This is more a problem of CGI.pm ( which Embperl uses under the hood ). > http://stackoverflow.com/questions/19610312/perl-cgi-passing-variable-in-post-with-json > may help you. > > 2015-03-30 18:58 GMT+02:00 Donavon >: > > Hello. > > I am creating an ajax call to an embperl script and I need > assistance in getting the script to work with json data sent with > "application/json" > > It works when I send data via javascript with: > request.setRequestHeader("Content-Type", > "application/x-www-form-urlencoded"); > request.send(encodeURLQueryString(data)); > > It doesn't work when I send data via javascript with: > request.setRequestHeader("Content-Type", "application/json"); > request.send(JSON.stringify(data)); > > > My submit form looks like this: > > submit.epl > [- > use JSON; # imports encode_json, decode_json, to_json and from_json. > > $fdat{test} = "test"; > $json = encode_json(\%fdat); > > $escmode = 0; > $http_headers_out{'Content-Type'} = "application/json; > charset=utf-8"; > print OUT $json; > -] > > > Thank You, > ~Donavon > > --------------------------------------------------------------------- > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org > > For additional commands, e-mail: embperl-help@perl.apache.org > > > > > > -- > -- > mit freundlichem Gruß, > > Frank Wesemann > Fotofinder GmbH USt-IdNr. DE812854514 > Software Entwicklung Web: http://www.fotofinder.com/ > Potsdamer Str. 96 Tel: +49 30 25 79 28 90 > 10785 Berlin Fax: +49 30 25 79 28 999 > > Sitz: Berlin > Amtsgericht Berlin Charlottenburg (HRB 73099) > Geschäftsführer: Ali Paczensky --------------010609020503060206050703 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hello and Thank You for the reply.

From the embperl documentation: " (Embperl uses CGI.pm internally to process forms encoded with multipart/form-data.)"

Does embperl convert "Content-Type: application/json" to "multipart/form-data"?

or

Does embperl  also use CGI.pm to populate %fdat?

In my script I am just using %fdat.  I am not loading nor using CGI.pm.   Any documentation that I have seen online refer to embperl and CGI.pm as separate, so unless I load CGI.pm or use "multipart/form-data" it should be a different issue.   Am I missing something?

Thank You,
~Donavon




On 4/2/2015 4:44 AM, Frank Wesemann wrote:
This is more a problem of CGI.pm ( which Embperl uses under the hood ).
may help you.

2015-03-30 18:58 GMT+02:00 Donavon <donl@mycopanet.com>:
Hello.

I am creating an ajax call to an embperl script and I need assistance in getting the script to work with json data sent with "application/json"

It works when I send data via javascript with:
  request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  request.send(encodeURLQueryString(data));

It doesn't work when I send data via javascript with:
  request.setRequestHeader("Content-Type", "application/json");
  request.send(JSON.stringify(data));


My submit form looks like this:

submit.epl
[-
use JSON; # imports encode_json, decode_json, to_json and from_json.

$fdat{test}  = "test";
$json        = encode_json(\%fdat);

$escmode = 0;
$http_headers_out{'Content-Type'}         = "application/json; charset=utf-8";
print OUT $json;
-]


Thank You,
~Donavon

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org




--
-- 
mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH         USt-IdNr. DE812854514
Software Entwicklung    Web: http://www.fotofinder.com/
Potsdamer Str. 96       Tel: +49 30 25 79 28 90
10785 Berlin            Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky

--------------010609020503060206050703--