home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / components / httprequestobserver.py < prev    next >
Encoding:
Python Source  |  2007-11-12  |  1.7 KB  |  39 lines

  1. # Miro - an RSS based video player application
  2. # Copyright (C) 2005-2007 Participatory Culture Foundation
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  17.  
  18. import logging
  19. from xpcom import components
  20. import locale
  21.  
  22. nsIObserver = components.interfaces.nsIObserver
  23. nsIHttpChannel = components.interfaces.nsIHttpChannel
  24.  
  25. class HTTPRequestObserver:
  26.     _com_interfaces_ = [ nsIObserver ]
  27.     _reg_clsid_ = "{59a204b1-7304-45bc-807f-4d108249770f}"
  28.     _reg_contractid_ = "@participatoryculture.org/dtv/httprequestobserver;1"
  29.     _reg_desc_ = "Democracy HTTP Request Observer"
  30.  
  31.     def observe(self, subject, topic, data):
  32.         if topic == "http-on-modify-request":
  33.               channel = subject.queryInterface(nsIHttpChannel)
  34.               currentLanguages = channel.getRequestHeader('Accept-Language')
  35.               language = locale.getdefaultlocale()[0].replace('_', '-')
  36.               channel.setRequestHeader("Accept-Language", language, False)
  37.               channel.setRequestHeader("Accept-Lanugage", currentLanguages, True)
  38.               channel.setRequestHeader("X-Miro", "1", False);
  39.