Re: [Tutor] + converted to 25 in http string

2007-04-24 Thread Martin Walsh
Hi,

govind goyal wrote:
 Hi,
 
 I am using http to automate my Access point(AP) configuration where I sent
 following strings to AP server through script.
 
 params = urllib.urlencode
 ({'WRegion':USA,'ssid':wifi,'ap':ap,'ssid_enable':ssid_enable,*
 'wire_mode':b+only,*
 'w_channel':6,'lan_ac':everyone,'int_ac':everyone})

You might consider having a look at the urllib quote_plus and
unquote_plus methods for clarification. I suspect the value you have
captured with ethereal is already quoted ('+' signs for spaces, etc) --
so you would have to unquote_plus it to find the correct value for use
in your script.

. urllib.unquote_plus('b+only')
'b only'

And, it appears that urllib.urlencode quotes the parameters while
constructing the query-string:

. params = urllib.urlencode({'write_mode': 'b only'})
. params
'write_mode=b+only'

HTH,
Marty

 
 Above string I captured using a tool ethereal and then implementing this in
 my script.
 But the problem is that when I run this script all configurations in AP are
 OK except the parameter marked as bold in above string.
 
 I used the same tool ethereal to see what string is actually passing to
 Access point while I run my script and I got following:
 
 params = urllib.urlencode
 ({'WRegion':USA,'ssid':wifi,'ap':ap,'ssid_enable':ssid_enable,*
 'wire_mode':b25only,*
 'w_channel':6,'lan_ac':everyone,'int_ac':everyone})
 
 In conclusion,the character + is getting converted into25 whenever I
 run
 script.Thats why all other configuartions are OK except above mentioned
 case.
 
 Can anybody help to resolve this issue?
 
 Best Regards,
 
 Govind Goyal
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] + converted to 25 in http string

2007-04-24 Thread Kent Johnson
govind goyal wrote:
 Hi,
  
 I am using http to automate my Access point(AP) configuration where I 
 sent following strings to AP server through script.
  
 params = 
 urllib.urlencode({'WRegion':USA,'ssid':wifi,'ap':ap,'ssid_enable':ssid_enable,*'wire_mode':b+only,*
  
 'w_channel':6,'lan_ac':everyone,'int_ac':everyone})
  
 Above string I captured using a tool ethereal and then implementing this 
 in my script.
 But the problem is that when I run this script all configurations in AP 
 are OK except the parameter marked as bold in above string.

'+' is not a valid character in parameters so it is escaped to %2B by 
urlencode:

In [10]: import urllib
In [11]: params = 
urllib.urlencode({'WRegion':USA,'ssid':wifi,'ap':ap,'ssid_enable':ssid_enable,'wire_mode':b+only,
 
'w_channel':6,'lan_ac':everyone,'int_ac':everyone})
In [12]: params
Out[12]: 
'ssid=wifissid_enable=ssid_enableap=apint_ac=everyoneWRegion=USAw_channel=6lan_ac=everyonewire_mode=b%2Bonly'


 I used the same tool ethereal to see what string is actually passing to 
 Access point while I run my script and I got following:
  
 params = 
 urllib.urlencode({'WRegion':USA,'ssid':wifi,'ap':ap,'ssid_enable':ssid_enable,*'wire_mode':b25only,
  
 *'w_channel':6,'lan_ac':everyone,'int_ac':everyone})

Where did this come from? This is not the output of ethereal...
  
 In conclusion,the character + is getting converted into25 whenever I 
 run script.Thats why all other configuartions are OK except above 
 mentioned case.

Interestingly, %25 is the escaped representation of '%'. So I wonder if 
your parameters are being url-encoded twice?

Can you show a little more of your code, and the actual string captured 
from ethereal?

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor