FAQ
I am sending a POST to a Catalyst app and according to the documention I
expected the request body to
contain the data I sent. Instead it holds a filename in the tmp
directory which contains the document. Is
this an expected behaviour?

e.g. in my test script

my $request = HTTP::Request->new(POST => 'http://linux:3000/svc/to/1001');
$request->content_type('text/text');
$request->content('THIS IS THE STRING');
my $response = $ua->request($request);


If I look at the value in $c->request->body in my controller I get
something
like '/tmp/LEVo4ciz1g'

And if I look at the content of the temp file I find my 'THIS IS THE
STRING'
text.

Is this a document problem or something else?

Regards
Ian

Search Discussions

  • Jonathan Rockway at Jan 26, 2008 at 3:47 pm

    * Ian Docherty writes:

    I am sending a POST to a Catalyst app and according to the documention
    I expected the request body to
    contain the data I sent. Instead it holds a filename in the tmp
    directory which contains the document. Is
    this an expected behaviour?

    e.g. in my test script

    my $request = HTTP::Request->new(POST => 'http://linux:3000/svc/to/1001');
    $request->content_type('text/text');
    $request->content('THIS IS THE STRING');
    my $response = $ua->request($request);
    Basically, HTTP::Body assumes you are sending your content as
    application/octet-stream, since it's not multipart/form-data or
    application/x-www-form-urlencoded (the two cases that it treats
    specially).

    Since file uploads are application/octet-stream, we put the data into
    a file. Maybe it would be better to keep it in memory unless
    Content-Length exceeds a certain length, but the current behavior is
    consistent and reliable, so I don't see why we should change it. It's
    really not that confusing.

    Finally, the "string" that you see in $c->req->body is actually an
    IO::File object, so you can easily suck the file in if the need
    arises.

    Regards,
    Jonathan Rockway
  • Ian Docherty at Jan 26, 2008 at 5:16 pm

    Jonathan Rockway wrote:
    * Ian Docherty <catalyst@iandocherty.com> writes:

    I am sending a POST to a Catalyst app and according to the documention
    I expected the request body to
    contain the data I sent. Instead it holds a filename in the tmp
    directory which contains the document. Is
    this an expected behaviour?

    e.g. in my test script

    my $request = HTTP::Request->new(POST => 'http://linux:3000/svc/to/1001');
    $request->content_type('text/text');
    $request->content('THIS IS THE STRING');
    my $response = $ua->request($request);
    Basically, HTTP::Body assumes you are sending your content as
    application/octet-stream, since it's not multipart/form-data or
    application/x-www-form-urlencoded (the two cases that it treats
    specially).

    Since file uploads are application/octet-stream, we put the data into
    a file. Maybe it would be better to keep it in memory unless
    Content-Length exceeds a certain length, but the current behavior is
    consistent and reliable, so I don't see why we should change it. It's
    really not that confusing.

    Finally, the "string" that you see in $c->req->body is actually an
    IO::File object, so you can easily suck the file in if the need
    arises.

    Regards,
    Jonathan Rockway

    ____________
    Thank you for that explanation. In the light of this does the following
    seem reasonable.

    I am creating a web service (xml over http) so the POST method would
    present an xml
    document to the controller using content-type text/xml and the
    controller would read it
    and parse it.

    Regards
    Ian

    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080126/d4b7909e/attachment.htm
  • Jennifer Ahn at Mar 8, 2008 at 1:34 am

    Ian Docherty wrote:
    Jonathan Rockway wrote:
    * Ian Docherty <catalyst@iandocherty.com> writes:

    I am sending a POST to a Catalyst app and according to the documention
    I expected the request body to
    contain the data I sent. Instead it holds a filename in the tmp
    directory which contains the document. Is
    this an expected behaviour?

    e.g. in my test script

    my $request = HTTP::Request->new(POST => 'http://linux:3000/svc/to/1001');
    $request->content_type('text/text');
    $request->content('THIS IS THE STRING');
    my $response = $ua->request($request);
    Basically, HTTP::Body assumes you are sending your content as
    application/octet-stream, since it's not multipart/form-data or
    application/x-www-form-urlencoded (the two cases that it treats
    specially).

    Since file uploads are application/octet-stream, we put the data into
    a file. Maybe it would be better to keep it in memory unless
    Content-Length exceeds a certain length, but the current behavior is
    consistent and reliable, so I don't see why we should change it. It's
    really not that confusing.

    Finally, the "string" that you see in $c->req->body is actually an
    IO::File object, so you can easily suck the file in if the need
    arises.

    Regards,
    Jonathan Rockway

    ____________
    Thank you for that explanation. In the light of this does the
    following seem reasonable.

    I am creating a web service (xml over http) so the POST method would
    present an xml
    document to the controller using content-type text/xml and the
    controller would read it
    and parse it.

    Regards
    Ian

    ------------------------------------------------------------------------

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    Hi Ian,

    I would like to implement ajax as you described above. In you controller
    method, how do you get the XML post file to parse through it? I am
    trying to read from STDIN and then use LibXML to parse through the XML.
    Is this the right approach?

    Thanks,
    Jennifer

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJan 26, '08 at 2:30p
activeMar 8, '08 at 1:34a
posts4
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase