# HTTP Response Status

**URL:** <https://www.ruby-forum.com/t/http-response-status/135565>\
**Category:** Rails\
**Created:** [April 23, 2008, 7:00am UTC](https://www.ruby-forum.com/t/http-response-status/135565 "2008-04-23T07:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 23, 2008, 7:00am UTC](https://www.ruby-forum.com/t/http-response-status/135565/1 "2008-04-23T07:00:00Z")

</div>

I’ve read this about rails actions,

‘Each action results in a response, which holds the headers and document  
to be sent to the userâ€˜s browser. The actual response object is  
generated automatically through the use of renders and redirects and  
requires no user intervention.’

This seems to work and make sense when a browser makes the POST, however  
we have a 3D engine called Unity contrsucting an HTTP POST to our server  
which passes a thumbnail of a rendered image. The controller saves the  
thumnail without any trouble and the method in the controller runs to  
completion however the browser isn’t redirected as it should becuase it  
is Unity (the 3D player) which made the HTTP POST and not the browser.  
So the parent html view which loads the player just sits there hung.

My question is, is there a way to send an HTTP Response (with a  
succesful status) back to the player to let it know that the save was  
succesful, and at that point we can take an action to redirect the page  
in javascript from the parent view.

simplified code is as follows:  
def update

```
    @virtual_item = VirtualItem.find(params[:id])
    @virtual_item.name = params[:name]
    if @virtual_item.update_attributes(params[:virtual_item])
      flash[:notice] = 'VirtualItem was successfully updated.'
      redirect_to :action => 'list'
    else
      render :action => 'edit'
    end

```

end

The attribute of @virtual\_item always are successfully updated, but the  
browser isn’t redirected to list. How do we send a response back to the  
Unity engine which made the POST to the update method?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 23, 2008, 8:39am UTC](https://www.ruby-forum.com/t/http-response-status/135565/2 "2008-04-23T08:39:38Z")

</div>

On 23 Apr 2008, at 06:00, Chris M. wrote:

> however  
> My question is, is there a way to send an HTTP Response (with a  
> succesful status) back to the player to let it know that the save was  
> succesful, and at that point we can take an action to redirect the  
> page  
> in javascript from the parent view.

Can’t your player check for a 200 (== render) or 30x (== redirect)  
response. Arguably this would be a case where using the standard xml  
type update would be more useful (eg if there are errors then you get  
some xml describing them rather than just a web form).

Fred

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 23, 2008, 4:53pm UTC](https://www.ruby-forum.com/t/http-response-status/135565/3 "2008-04-23T16:53:27Z")

</div>

Frederick C. wrote:

> On 23 Apr 2008, at 06:00, Chris M. wrote:
> 
> > however  
> > My question is, is there a way to send an HTTP Response (with a  
> > succesful status) back to the player to let it know that the save was  
> > succesful, and at that point we can take an action to redirect the  
> > page  
> > in javascript from the parent view.
> 
> Can’t your player check for a 200 (== render) or 30x (== redirect)  
> response. Arguably this would be a case where using the standard xml  
> type update would be more useful (eg if there are errors then you get  
> some xml describing them rather than just a web form).
> 
> Fred

Yes I do believe the player can check for the response. However, it  
isn’t getting any resonse back from the controller which is strange.  
The page (and embedded) player just sit there waiting for a response.  
We can write a event function within the player that says ‘Ok we’ve sent  
our data now do something’ but that isn’t ideal. It would be nice if  
it could check for a successful response and then execute the next  
action we choose to take.
