[Kepler-Project] WSAPI and redirects

Jonathan Nalley jon at bluebot.org
Mon Sep 1 20:31:01 GMT+2 2008


Thanks!

Guess I should have read the RFC first ;-)

Your proposed solution sounds good.  Having a redirect method in
wsapi.respons will be helpful.

Regards,

Jon Nalley

On Mon, Sep 1, 2008 at 5:12 PM, Fabio Mascarenhas <mascarenhas at acm.org> wrote:
> Hi,
>
> >From RFC2616:
>
> ---------------------------------
> 10.3.3 302 Found
>
> The requested resource resides temporarily under a different URI.
> Since the redirection might be altered on occasion, the client SHOULD
> continue to use the Request-URI for future requests. This response is
> only cacheable if indicated by a Cache-Control or Expires header
> field.
>
> The temporary URI SHOULD be given by the Location field in the
> response. Unless the request method was HEAD, the entity of the
> response SHOULD contain a short hypertext note with a hyperlink to the
> new URI(s).
>
> If the 302 status code is received in response to a request other than
> GET or HEAD, the user agent MUST NOT automatically redirect the
> request unless it can be confirmed by the user, since this might
> change the conditions under which the request was issued.
>
>      Note: RFC 1945 and RFC 2068 specify that the client is not allowed
>      to change the method on the redirected request.  However, most
>      existing user agent implementations treat 302 as if it were a 303
>      response, performing a GET on the Location field-value regardless
>      of the original request method. The status codes 303 and 307 have
>      been added for servers that wish to make unambiguously clear which
>      kind of reaction is expected of the client.
> ---------------------------------
>
> I think a better solution is to have Xavante generate the "short
> hypertext note" when you do not provide one. I will work on that, and
> also add a redirect method to wsapi.response (I thought I had already
> done it :-) ).
>
> --
> Fabio Mascarenhas
>
> On Mon, Sep 1, 2008 at 6:58 PM, Jon Nalley <lists at bluebot.org> wrote:
>>
>> Hello,
>>
>> I have been playing around with xavante and WSAPI.  I noticed that
>> when my WSAPI app generates a HTTP redirect using the following code:
>>
>>    local res = wsapi.response.new()
>>    res.headers = { ["Location"] = location }
>>    res.status = status or "302 Found"
>>    return res:finish()
>>
>> The actual HTTP status code was "204 No Content" even though I was
>> specifically setting "302 Found".
>>
>> I found the following code in xavante.httpd that seems to be
>> overriding my status code if the content length is zero:
>>
>>   if not res.sent_headers then
>>        res.statusline = "HTTP/1.1 204 No Content"
>>        res.headers["Content-Length"] = 0
>>   end
>>
>> To fix the issue, I changed the "if not res.sent_headers then" to "if
>> not res.sent_headers and not res.headers then".  So the only way a
>> "204" would be generated is if I failed to set any headers and the
>> content length was zero.
>>
>> Not sure if this is the right way to fix it or not.  Am I missing
>> something else?  I should be able to send a re-direct with no content
>> correct?
>>
>> Regards,
>>
>> Jon Nalley
>>
>> _______________________________________________
>> Kepler-Project mailing list
>> Kepler-Project at lists.luaforge.net
>> http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
>> http://www.keplerproject.org/
>
> _______________________________________________
> Kepler-Project mailing list
> Kepler-Project at lists.luaforge.net
> http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
> http://www.keplerproject.org/
>



More information about the Kepler-Project mailing list