Hello everyone,

I'm currently working on porting an application to using the Google
App Engine, but I've run into a very odd bit of behavior.  Sometimes I
need to redirect to a site that expects query strings to be in EUC-JP
instead of UTF-8, and self.redirect() doesn't set the location
correctly when I try to do so.  Here is the incorrect behavior, which
only occurs when run on the cloud:

% wget -O /dev/null --server-response 'https://super-nubs.appspot.com/?
cmd=mgoo+%E4%B8%AD%E5%B3%B6%E3%81%BF%E3%82%86%E3%81%8Dee'
--2011-11-01 10:25:28--  
https://super-nubs.appspot.com/?cmd=mgoo+%E4%B8%AD%E5%B3%B6%E3%81%BF%E3%82%86%E3%81%8Dee
Resolving super-nubs.appspot.com... 74.125.127.141
Connecting to super-nubs.appspot.com|74.125.127.141|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 302 Found
  Content-Type: text/html; charset=utf-8
  Cache-Control: max-age=172800
  Date: Tue, 01 Nov 2011 17:25:28 GMT
  Server: Google Frontend
  Content-Length: 0
  Connection: Keep-Alive
Location: unspecified
ERROR: Redirection (302) without location.


Here is the correct behavior, running on a local instance:
% wget -O /dev/null --server-response 'http://127.0.0.1:8080/?cmd=mgoo+
%E4%B8%AD%E5%B3%B6%E3%81%BF%E3%82%86%E3%81%8Dee'
--2011-11-01 10:26:30--  
http://127.0.0.1:8080/?cmd=mgoo+%E4%B8%AD%E5%B3%B6%E3%81%BF%E3%82%86%E3%81%8Dee
Connecting to 127.0.0.1:8080... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 302 Moved Temporarily
  Server: Development/1.0
  Date: Tue, 01 Nov 2011 17:26:30 GMT
  Content-Type: text/html; charset=utf-8
  Cache-Control: max-age=172800
  Location: http://music.goo.ne.jp/search/result.php?n=\303\346\305\347\244ߤ椭ee
  Content-Length: 0
Location: 
http://music.goo.ne.jp/search/result.php?n=%C3%E6%C5%E7%A4%DF%A4%E6%A4%ADee
[following]
--2011-11-01 10:26:30--  
http://music.goo.ne.jp/search/result.php?n=%C3%E6%C5%E7%A4%DF%A4%E6%A4%ADee
Resolving music.goo.ne.jp... 210.150.25.68
Connecting to music.goo.ne.jp|210.150.25.68|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 200 OK
  Date: Tue, 01 Nov 2011 17:26:31 GMT
  Server: Apache
  Cache-Control: no-store, no-cache, must-revalidate
  Pragma: no-cache
  Content-Type: text/html
  Set-Cookie: BBTracking=173.36.196.10.1320168391262803; path=/;
expires=Fri, 29-Oct-21 17:26:31 GMT
  Set-Cookie: NGUserID=dummy; expires=Wed, 01-Jan-2003 00:00:00 GMT;
path=/; domain=music.goo.ne.jp
Length: unspecified [text/html]
Saving to: “/dev/null”

 
[ <=>                                                                           
                                                                                
                                       ]
27,978      --.-K/s   in 0.08s

2011-11-01 10:26:31 (345 KB/s) - “/dev/null” saved [27978]


Lastly, here is the bit of code identical on both the cloud and the
local instance that handles the actual redirect.  I have not tried the
above cmd value before, so I know it's not in memcache:

                content = url_parse(row.content, cmd, argv, cmb)
                content = content.replace(' ', '%20')
                content = content.encode(row.encoding)
                self.response.headers['Cache-Control'] = 'max-
age=172800'
                memcache.set(digest, content, 3600)
                self.redirect(content)

row.encoding = 'EUC-JP' in this case.  If row.encoding = 'UTF-8' (the
default) the behavior on the local and cloud instances is the same.

What can I do to get the redirect working when Location can't be
UTF-8?

Thanks,

- Neil

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to