[Laszlo-dev] Rest Support
André Bargull
a.bargull at intensis.de
Sun Feb 24 08:58:01 PST 2008
That should be sufficient:
<%
response.sendError(401);
//or response.sendError(401, "My message");
%>
Concerning non-proxied SWF (Adobe-Doc for ActionScript "XML#onHTTPStatus"):
> If Flash Player cannot get a status code from the server, or if it
> cannot communicate with the server, the default value of 0 is passed
> to your ActionScript code. A value of 0 can be generated in any player
> (for example, if a malformed URL is requested), and a value of 0 is
> always generated by the Flash Player plug-in when it is run in the
> following browsers, which do not pass HTTP status codes to the player:
> Netscape, Mozilla, Safari, Opera, and Internet Explorer for the Macintosh.
So for SWF, you must run in proxied-mode to have at least a chance to
get the http-status (i.e. through the LPS).
> I'm taking a look at this. Can you tell me if there is an easy way to
> you get Tomcat server to return a 401 code? If I mark a file as
> unreadable, I am getting back a 404 code. <canvas width="100%"
> height="80%" debug="true"> <debug fontsize="12"/> <dataset
> name="mydata" src="http:foo.xml" onerror="Debug.write('onerror',
> this.errorstring)" ondata="Debug.write('ondata', this.data)"
> request="true"/> </canvas> this returns the following in the debugger
> in swf8 ?LoadObj#0| err.lzx (loading)? ?LzLoader#1| err.lzx (loading)?
> ERROR: data source error for
> http://127.0.0.1:8080/trunk/test/post2/foo.xml: HTTP Status code:
> 404:Not Found onerror data source error for
> http://127.0.0.1:8080/trunk/test/post2/foo.xml: HTTP Status code:
> 404:Not Found lzx> mydata.errorstring 'data source error for
> http://127.0.0.1:8080/trunk/test/post2/foo.xml: HTTP Status code:
> 404:Not Found' lzx> By the way, you won't be able to support full REST
> API transactions in non-proxied mode in swf7/8 because the Flash
> player does not let you specify PUT or DELETE request . These are
> supported by the proxy server though, I am pretty sure. If they aren't
> then it's a bug.. In DHTML, I believe PUT and DELETE request methods
> are supported in SOLO mode. On Sun, Feb 24, 2008 at 8:07 AM, Elias
> Khalil <elias.khalil at g.ho.st> wrote:
>> > I am trying to call REST APIs from openlaszlo. I tried to make a dataset
>> > http request and it worked fine on success. But in case where the REST
>> > returns an error like HTTP Error 401 ? Unauthorized I can't read the error
>> > string or code. It behaves as the following:
>> > On proxied mode: dataset.getErrorString()always return null while in
>> > debugger there is a message showing the error type but we can't access it
>> > On non proxied mode: calling dataset.getErrorString() result in error
>> > "client could not parse XML from server"
>> > Using Xmlhttprequest is also not helpful where it always cast errors types
>> > to http error 500
>> >
>> > In order to support calling basic REST APIs, I need to get a clear HTTP
>> > Error code and also be able to read the http content in case of error.
>> >
>>
>
>
>
> -- Henry Minsky Software Architect hminsky at laszlosystems.com
More information about the Laszlo-dev
mailing list