Re: [Cppcms-users] Can't jump to another page from server side
Brought to you by:
artyom-beilis
|
From: 陈抒 <csf...@gm...> - 2012-01-08 13:49:36
|
Hello,Artyom:
It's easy to retrieve detail via Chromium debug mode.
1. Request URL:
http://localhost:8081/kaimei/create_account
2. Request Method:
POST
3. Status Code:
302 Found
4. Request Headersview parsed
1. POST /kaimei/create_account HTTP/1.1 Host: localhost:8081
Connection: keep-alive Content-Length: 33 Origin:
http://localhost:8081 X-Requested-With: XMLHttpRequest User-Agent:
Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (KHTML, like Gecko)
Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2
Content-Type: application/x-www-form-urlencoded Accept: */*
Referer: http://localhost:8081/kaimei/register
Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Cookie:
cppcms_session=Id308630366b70e1e8950182a3389874a
5. Form Dataview URL encoded
1. email:
cd...@gm...
2. pwd:
123456
6. Response Headersview source
1. Connection:
close
2. Content-Encoding:
gzip
3. Content-Type:
text/html; charset=utf-8
4. Location:
http://localhost:8081/kaimei/user_home
5. Server:
CppCMS-Embedded/0.99.11
6. Set-Cookie:
cppcms_session=Id308630366b70e1e8950182a3389874a; Max-Age=600;
Path=/; Version=1
7. Status:
302 Found
8. X-Powered-By:
CppCMS/0.99.11
1. Request URL:
http://localhost:8081/kaimei/user_home
2. Request Method:
GET
3. Status Code:
200 Ok
4. Request Headersview source
1. Accept:
*/*
2. Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.3
3. Accept-Encoding:
gzip,deflate,sdch
4. Accept-Language:
en-US,en;q=0.8
5. Connection:
keep-alive
6. Cookie:
cppcms_session=Id308630366b70e1e8950182a3389874a
7. Host:
localhost:8081
8. Referer:
http://localhost:8081/kaimei/register
9. User-Agent:
Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.2 (KHTML, like Gecko)
Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2
10. X-Requested-With:
XMLHttpRequest
5. Response Headersview source
1. Connection:
close
2. Content-Encoding:
gzip
3. Content-Type:
text/html; charset=utf-8
4. Server:
CppCMS-Embedded/0.99.11
5. X-Powered-By:
CppCMS/0.99.11
陈抒
Best regards
http://blog.csdn.net/sheismylife
On Sun, Jan 8, 2012 at 5:11 PM, Artyom Beilis <art...@ya...> wrote:
> Can you send a headers that are returned by the web server, for example
> simulate the request with wget
>
> wget -d http://some/url
>
> And provide output (-d debug - prints all headers)
>
> So we can see what is send by the server.
>
>
>
> Artyom Beilis
> --------------
> CppCMS - C++ Web Framework: http://cppcms.sf.net/
> CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/
>
> ------------------------------
> *From:* 陈抒 <csf...@gm...>
> *To:* Artyom Beilis <art...@ya...>;
> cpp...@li...
> *Sent:* Sunday, January 8, 2012 10:38 AM
> *Subject:* Re: [Cppcms-users] Can't jump to another page from server side
>
> Hello,Artyom:
> Please see my comments below.
>
> 陈抒
> Best regards
> http://blog.csdn.net/sheismylife
>
>
> On Sun, Jan 8, 2012 at 3:48 PM, Artyom Beilis <art...@ya...> wrote:
>
> 1. Are you sure you call response().set_redirect_header(...) before you
> call response().out()? Because this is likely the reason it may not work.
>
> >> yes.
>
>
> 2. Show me the code :-)
>
> My codes looks like so:
>
> kaimei_web_site::kaimei_web_site(cppcms::service
> &srv):cppcms::application(srv){
> //web page
> dispatcher().assign("/welcome" , &kaimei_web_site::welcome , this ,
> 1); //first page
> dispatcher().assign("/register" , &kaimei_web_site::register_client ,
> this , 2); //register a new account on this page
> ....
> //restful web method called by Javascript form client-side
> dispatcher().assign("/send_email" , &kaimei_web_site::save_email ,
> this , 7);
> dispatcher().assign("/create_account?(.+)" ,
> &kaimei_web_site::create_account , this , 8);
> ....
>
> }
>
>
> //render the register html page for user
> void kaimei_web_site::register_client(std::string url){
> BOOSTER_INFO("kaimei_web_site") << "enter register_client function";
> init_session();
>
> string language = this->session().get("language");
> language_cache& cache = app_singleton_holder::Instance().cache();
> content::welcome_content content =
> cache.get(language).clone_welcome_content();
> configuration& config = app_singleton_holder::Instance().config();
> content.base_uri=config.base_uri;
> content.jsonp= config.jsonp;
> render("create_account","create_account_view",content);
> }
>
>
> void kaimei_web_site::create_account(std::string str){
> try{
> init_session();
> string email = request().post().find("email")->second;
> string pwd = request().post().find("pwd")->second;
> user_manager::create_account(email,pwd);
> string language = this->session().get("language");
>
> shared_ptr<web_user> user = user_manager::login(email,pwd);
> if(user){
> BOOSTER_INFO("kaimei_web_site") << "login succeeded";
> this->session()["email"]=user->email;
> this->session()["user_id"]=user->oid;
> configuration& config = app_singleton_holder::Instance().config();
> response().set_redirect_header(config.jsonp + "/user_home"); //I try
> to redirect to new page but failed
> }else{
> kaimei::response res;
> res.message="Login failed!";
> res.status=kaimei::response::LOGIN_ERROR;
> response().out()<<cppcms::json::value(res);
> }
> }catch(std::exception &ex){
> kaimei::response res;
> res.message=ex.what();
> res.status=kaimei::response::CREATE_ACCOUNT_ERROR;
> response().out()<<cppcms::json::value(res);
> }
>
> }
>
> the real value of config.jsonp
> (gdb) p config.jsonp
> $1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>>
> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data
> fields>}, _M_p = 0x80c6e24 "http://localhost:8081/kaimei"}}
>
>
> 3. Small example that reproduces the problem.
>
> >>I can create it if necessary,but need some hours.
>
>
> 4. What is the web server you are using, what protocol?
> (some web servers like nginx, do not handle Status header properly
> over SCGI protocol).
>
>
> >> In my development environment,I just use cppcms and HTTP protocol.
>
>
> Artyom Beilis
> --------------
> CppCMS - C++ Web Framework: http://cppcms.sf.net/
> CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/
>
> ------------------------------
> *From:* 陈抒 <csf...@gm...>
> *To:* cpp...@li...
> *Sent:* Sunday, January 8, 2012 9:30 AM
> *Subject:* [Cppcms-users] Can't jump to another page from server side
>
> Hello,
> I tried response().set_redirect_header(...) function ,but it doesn't
> work.
> If one user registers his/her account into my web site successfully,the
> page will jump to user's home page automatically.
>
> 陈抒
> Best regards
> http://blog.csdn.net/sheismylife
>
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
>
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
>
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
>
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
|