librelist archives

« back to archive

Mongrel2 ignore anchor parameters?

Mongrel2 ignore anchor parameters?

From:
Tang Daogang
Date:
2011-02-16 @ 05:47
Dear Shaw,

I input the following URL:
http://localhost:6767/page/index?xxx=123#edit/index to the address bar of
firefox, and monitor the log info in tir. I can see

PATH    /page/index/
URI    /page/index/?xxx=123
QUERY    xxx=123
referer    http://localhost:6767/page/index/?xxx=123

in the req.headers, but can't get the last part anchor?

Does mongrel2 ingnore anchor parameters when send message?

Thx.

-- 
Nothing is impossible.

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Zed A. Shaw
Date:
2011-02-16 @ 06:56
On Wed, Feb 16, 2011 at 01:47:15PM +0800, Tang Daogang wrote:
> Dear Shaw,
> 
> I input the following URL:
> http://localhost:6767/page/index?xxx=123#edit/index to the address bar of
> firefox, and monitor the log info in tir. I can see

I got bit by that too.  Apparently browsers aren't supposed to send this
since it's just used for anchoring inside a document.

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Loic d'Anterroches
Date:
2011-02-16 @ 08:00
Hello,

On 2011-02-16 07:56, Zed A. Shaw wrote:
> On Wed, Feb 16, 2011 at 01:47:15PM +0800, Tang Daogang wrote:
>> I input the following URL:
>> http://localhost:6767/page/index?xxx=123#edit/index to the address bar of
>> firefox, and monitor the log info in tir. I can see
> 
> I got bit by that too.  Apparently browsers aren't supposed to send this
> since it's just used for anchoring inside a document.

Per RFC they will never send this part. This is why we have a big
problem with the new twitter URLs. The anchor simply means:

Retrieve the document: http://localhost:6767/page/index?xxx=123
Then, after rendering, go to the anchor edit/index in the document.

# the anchor is totally client side. This is good too, because it means
that if you have a table of content in a big page, a click will not send
another HTTP request.

So, if you design your URL space to require the anchor, you are doing
something wrong with respect to the REST principles. You could rework
your space to have something like:

http://localhost:6767/page/123 : see the page 123
http://localhost:6767/edit/page/123 : edit page 123

loïc

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Tang Daogang
Date:
2011-02-16 @ 08:17
On Wed, Feb 16, 2011 at 4:00 PM, Loic d'Anterroches <loic@ceondo.com> wrote:

> Hello,
>
> On 2011-02-16 07:56, Zed A. Shaw wrote:
> > On Wed, Feb 16, 2011 at 01:47:15PM +0800, Tang Daogang wrote:
> >> I input the following URL:
> >> http://localhost:6767/page/index?xxx=123#edit/index to the address bar
> of
> >> firefox, and monitor the log info in tir. I can see
> >
> > I got bit by that too.  Apparently browsers aren't supposed to send this
> > since it's just used for anchoring inside a document.
>
> Per RFC they will never send this part. This is why we have a big
> problem with the new twitter URLs. The anchor simply means:
>
> Retrieve the document: http://localhost:6767/page/index?xxx=123
> Then, after rendering, go to the anchor edit/index in the document.
>
> # the anchor is totally client side. This is good too, because it means
> that if you have a table of content in a big page, a click will not send
> another HTTP request.
>
> So, if you design your URL space to require the anchor, you are doing
> something wrong with respect to the REST principles.

Oh, REST principles said that?


> You could rework
> your space to have something like:
>
> http://localhost:6767/page/123 : see the page 123
> http://localhost:6767/edit/page/123 : edit page 123
>
> Thanks for your suggestion, I do it like that before. But I met a problem,
I think it is the conflicts between Web2.0 and the HTTP standard:

I need to use jquery to load a new page fragment in to current web page, and
modify the URL by javascript correspondingly, if I modify the URL,

window.location.href = 'new page url'

it will do a redirect action by browser, but I don't want to be that.

And, if I change the anchor:
window.location.hash = 'new page anchor'
page won't redirect automatically and new url will indicate the new page.

And next time, I want to locate this new page directly from browser address
bar, I want to copy this new url (containing anchors) and paste to address
bar to make a request. If the ahchor is not sent to server, it won't locate
the new page correctly.

Then, How to solve this conflict?

I don't know whether I have describe this problem clearly?





> loïc
>



-- 
Nothing is impossible.

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Austin Wise
Date:
2011-02-16 @ 08:33
I recently wanted to try using anchors like you describe and found
Sammy.js to be a nice way to achieve this.
http://sammyjs.org/
It does handle the case of copying the URL and still having the right
view pop up.  If you don't end up using it it's small enough that you
could take it apart and see how it works.

On Wed, Feb 16, 2011 at 12:17 AM, Tang Daogang <daogangtang@gmail.com> wrote:
>
>
> On Wed, Feb 16, 2011 at 4:00 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
>>
>> Hello,
>>
>> On 2011-02-16 07:56, Zed A. Shaw wrote:
>> > On Wed, Feb 16, 2011 at 01:47:15PM +0800, Tang Daogang wrote:
>> >> I input the following URL:
>> >> http://localhost:6767/page/index?xxx=123#edit/index to the address bar
>> >> of
>> >> firefox, and monitor the log info in tir. I can see
>> >
>> > I got bit by that too.  Apparently browsers aren't supposed to send this
>> > since it's just used for anchoring inside a document.
>>
>> Per RFC they will never send this part. This is why we have a big
>> problem with the new twitter URLs. The anchor simply means:
>>
>> Retrieve the document: http://localhost:6767/page/index?xxx=123
>> Then, after rendering, go to the anchor edit/index in the document.
>>
>> # the anchor is totally client side. This is good too, because it means
>> that if you have a table of content in a big page, a click will not send
>> another HTTP request.
>>
>> So, if you design your URL space to require the anchor, you are doing
>> something wrong with respect to the REST principles.
>
> Oh, REST principles said that?
>
>>
>> You could rework
>> your space to have something like:
>>
>> http://localhost:6767/page/123 : see the page 123
>> http://localhost:6767/edit/page/123 : edit page 123
>>
> Thanks for your suggestion, I do it like that before. But I met a problem, I
> think it is the conflicts between Web2.0 and the HTTP standard:
>
> I need to use jquery to load a new page fragment in to current web page, and
> modify the URL by javascript correspondingly, if I modify the URL,
>
> window.location.href = 'new page url'
>
> it will do a redirect action by browser, but I don't want to be that.
>
> And, if I change the anchor:
> window.location.hash = 'new page anchor'
> page won't redirect automatically and new url will indicate the new page.
>
> And next time, I want to locate this new page directly from browser address
> bar, I want to copy this new url (containing anchors) and paste to address
> bar to make a request. If the ahchor is not sent to server, it won't locate
> the new page correctly.
>
> Then, How to solve this conflict?
>
> I don't know whether I have describe this problem clearly?
>
>
>
>
>>
>> loïc
>
>
>
> --
> Nothing is impossible.
>
>

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Tang Daogang
Date:
2011-02-16 @ 07:52
I use firefox LiveHttp extension to montior the headers sent by firefox.
the log info is:
------------------------------------------------------------
http://localhost:6767/pages/index/?xxx=123*#edit/index/ *

GET /pages/index/?xxx=123 HTTP/1.1
Host: localhost:6767
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.8)
Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: session="APP-f4a619a2f181ccccd4812e9f664e9029"
Cache-Control: max-age=0

HTTP/1.1 200 OK
Content-Length: 3141
Content-Type: text/html
Server: Mongrel2
------------------------------------------------------------

But, if the anchor info is not sent to the server, how to locate the exact
target by many ajax web sites, such as gmail.

The url of the page now I am writing email on is:
https://mail.google.com/mail/?shva=1#label/Mongrel2%26Tir/12e2d021afc30cb2

next time I open firefox, paste this url into address bar to access gmail,
gmail will jump to this page exactly automatically. How does it reach it?

BR.

On Wed, Feb 16, 2011 at 2:56 PM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:

> On Wed, Feb 16, 2011 at 01:47:15PM +0800, Tang Daogang wrote:
> > Dear Shaw,
> >
> > I input the following URL:
> > http://localhost:6767/page/index?xxx=123#edit/index to the address bar
> of
> > firefox, and monitor the log info in tir. I can see
>
> I got bit by that too.  Apparently browsers aren't supposed to send this
> since it's just used for anchoring inside a document.
>
> --
> Zed A. Shaw
> http://zedshaw.com/
>



-- 
Nothing is impossible.

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Isaac Force
Date:
2011-02-16 @ 08:29
On Tue, Feb 15, 2011 at 11:52 PM, Tang Daogang <daogangtang@gmail.com> wrote:
> I use firefox LiveHttp extension to montior the headers sent by firefox.
> the log info is:
> ------------------------------------------------------------
> http://localhost:6767/pages/index/?xxx=123#edit/index/
>
> GET /pages/index/?xxx=123 HTTP/1.1

You can see in the line above that the #edit/index/ is not sent to the
server by FF; it ends at the GET arg.

> The url of the page now I am writing email on is:
> https://mail.google.com/mail/?shva=1#label/Mongrel2%26Tir/12e2d021afc30cb2
>
> next time I open firefox, paste this url into address bar to access gmail,
> gmail will jump to this page exactly automatically. How does it reach it?

The #anchor information is parsed by JS and the intended state of the
UI is reinstated. You can see this happening on complex pages such as
Gmail; it initially loads the page, then there's a slight delay while
the UI is filling the intended state in via AJAX calls and the like.
This is currently the only way (That I'm aware) of freezing/unfreezing
dynamic browser state via copyable URLs without causing the browser to
navigate away and load the new address.

HTML5 addresses this with the new window.history functions.

-Isaac

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Ryan Kelly
Date:
2011-02-16 @ 08:19
On Wed, 2011-02-16 at 15:52 +0800, Tang Daogang wrote:
> I use firefox LiveHttp extension to montior the headers sent by
> firefox.
> the log info is:
> ------------------------------------------------------------
> http://localhost:6767/pages/index/?xxx=123#edit/index/
>  
> GET /pages/index/?xxx=123 HTTP/1.1 
> Host: localhost:6767 
> User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.8)
> Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8 
> Accept: text/html,application/xhtml
> +xml,application/xml;q=0.9,*/*;q=0.8 
> Accept-Language: zh-cn,zh;q=0.5 
> Accept-Encoding: gzip,deflate 
> Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7 
> Keep-Alive: 115 
> Connection: keep-alive 
> Cookie: session="APP-f4a619a2f181ccccd4812e9f664e9029" 
> Cache-Control: max-age=0 
>  
> HTTP/1.1 200 OK 
> Content-Length: 3141 
> Content-Type: text/html 
> Server: Mongrel2 
> ------------------------------------------------------------
> 
> But, if the anchor info is not sent to the server, how to locate the
> exact target by many ajax web sites, such as gmail.
> 
> The url of the page now I am writing email on is:
> https://mail.google.com/mail/?shva=1#label/Mongrel2%
> 26Tir/12e2d021afc30cb2
> 
> next time I open firefox, paste this url into address bar to access
> gmail, gmail will jump to this page exactly automatically. How does it
> reach it?


They likely use client-side javascript to extract the anchor portion,
convert it into a proper server-side URL, and use XMTHttpRequest to
fetch the content in the background.

Try using firebug or similar to see what requests gmail actually makes
to the server.


  Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
ryan@rfk.id.au        |  http://www.rfk.id.au/ramblings/gpg/ for details

Re: [mongrel2] Mongrel2 ignore anchor parameters?

From:
Tang Daogang
Date:
2011-02-16 @ 08:37
On Wed, Feb 16, 2011 at 4:19 PM, Ryan Kelly <ryan@rfk.id.au> wrote:

> On Wed, 2011-02-16 at 15:52 +0800, Tang Daogang wrote:
> > I use firefox LiveHttp extension to montior the headers sent by
> > firefox.
> > the log info is:
> > ------------------------------------------------------------
> > http://localhost:6767/pages/index/?xxx=123#edit/index/
> >
> > GET /pages/index/?xxx=123 HTTP/1.1
> > Host: localhost:6767
> > User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.8)
> > Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8
> > Accept: text/html,application/xhtml
> > +xml,application/xml;q=0.9,*/*;q=0.8
> > Accept-Language: zh-cn,zh;q=0.5
> > Accept-Encoding: gzip,deflate
> > Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
> > Keep-Alive: 115
> > Connection: keep-alive
> > Cookie: session="APP-f4a619a2f181ccccd4812e9f664e9029"
> > Cache-Control: max-age=0
> >
> > HTTP/1.1 200 OK
> > Content-Length: 3141
> > Content-Type: text/html
> > Server: Mongrel2
> > ------------------------------------------------------------
> >
> > But, if the anchor info is not sent to the server, how to locate the
> > exact target by many ajax web sites, such as gmail.
> >
> > The url of the page now I am writing email on is:
> > https://mail.google.com/mail/?shva=1#label/Mongrel2%
> > 26Tir/12e2d021afc30cb2
> >
> > next time I open firefox, paste this url into address bar to access
> > gmail, gmail will jump to this page exactly automatically. How does it
> > reach it?
>
>
> They likely use client-side javascript to extract the anchor portion,
> convert it into a proper server-side URL, and use XMTHttpRequest to
> fetch the content in the background.
>
> Try using firebug or similar to see what requests gmail actually makes
> to the server.
>
> OK, I have seen it. After it get the basic page, it make some new post
request to server to get the inner content.

Thank you very much.


>
>  Ryan
>
>
> --
> Ryan Kelly
> http://www.rfk.id.au  |  This message is digitally signed. Please visit
> ryan@rfk.id.au        |  http://www.rfk.id.au/ramblings/gpg/ for details
>
>


-- 
Nothing is impossible.