[BaseHTTPServer/SimpleHTTPServer] Remove "Server:" header

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sebsauvage@gmail.com

    [BaseHTTPServer/SimpleHTTPServer] Remove "Server:" header

    Hello.


    I'm using SimpleHTTPServe r (work well) but it always sends "Server"
    header in response:
    "Server: SimpleHTTP/0.6 Python/2.5.1"

    How can I remove that ?

    I tried:
    self.server_ver sion = ""
    self.sys_versio n = ""

    but the header is still sent, empty.

    I there a way to remove the "Server:" header completely ?



    Thanks.
  • Gary M. Josack

    #2
    Re: [BaseHTTPServer/SimpleHTTPServe r] Remove "Server:&q uot; header

    you've got ?self.send_head er('Server', self.version_st ring()) in the
    send_response method of the BaseHTTPRequest Handler class in the
    BaseHTTPServer module. Long story, short, it's going to be a lot of work
    to get rid of.

    sebsauvage@gmai l.com wrote:
    Hello.
    >
    >
    I'm using SimpleHTTPServe r (work well) but it always sends "Server"
    header in response:
    "Server: SimpleHTTP/0.6 Python/2.5.1"
    >
    How can I remove that ?
    >
    I tried:
    self.server_ver sion = ""
    self.sys_versio n = ""
    >
    but the header is still sent, empty.
    >
    I there a way to remove the "Server:" header completely ?
    >
    >
    >
    Thanks.
    --

    >

    Comment

    • Gabriel Genellina

      #3
      Re: [BaseHTTPServer/SimpleHTTPServe r] Remove "Server:&q uot; header

      sebsauvage@gmai l.com wrote:
      >I'm using SimpleHTTPServe r (work well) but it always sends "Server"
      >header in response:
      >How can I remove that ?
      En Fri, 03 Oct 2008 11:11:34 -0300, Gary M. Josack <gary@byoteki.c om>
      escribió:
      you've got ?self.send_head er('Server', self.version_st ring()) in the
      send_response method of the BaseHTTPRequest Handler class in the
      BaseHTTPServer module. Long story, short, it's going to be a lot of work
      to get rid of.
      One can always write a customized RequestHandler, and just copy the
      send_response method omiting the offending line. (Ok, you have to check
      whether it still works with the next Python release... a warning triggered
      by a new sys.version would be enough to remember that)

      --
      Gabriel Genellina

      Comment

      • sebsauvage@gmail.com

        #4
        Re: Remove &quot;Server:&q uot; header

        On 3 oct, 20:17, "Gabriel Genellina" <gagsl-...@yahoo.com.a rwrote:
        sebsauv...@gmai l.com wrote:
        I'm using SimpleHTTPServe r (work well) but it always sends "Server"
        header in response:
        How can I remove that ?
        >
        En Fri, 03 Oct 2008 11:11:34 -0300, Gary M. Josack <g...@byoteki.c om 
        escribió:
        >
        you've got ?self.send_head er('Server', self.version_st ring()) in the  
        send_response method of the BaseHTTPRequest Handler class in the  
        BaseHTTPServer module. Long story, short, it's going to be a lot of work  
        to get rid of.
        >
        One can always write a customized RequestHandler, and just copy the  
        send_response method omiting the offending line. (Ok, you have to check  
        whether it still works with the next Python release... a warning triggered  
        by a new sys.version would be enough to remember that)
        I see. No choice but to override the method with a copy of the
        source :-/
        I guess I'll have to do with that.

        Thanks.


        Comment

        • Gabriel Genellina

          #5
          Re: Remove &quot;Server:&q uot; header

          En Fri, 03 Oct 2008 17:46:31 -0300, sebsauvage@gmai l.com
          <sebsauvage@gma il.comescribió:
          On 3 oct, 20:17, "Gabriel Genellina" <gagsl-...@yahoo.com.a rwrote:
          sebsauv...@gmai l.com wrote:
          >I'm using SimpleHTTPServe r (work well) but it always sends "Server"
          >header in response:
          >How can I remove that ?
          >>
          >En Fri, 03 Oct 2008 11:11:34 -0300, Gary M. Josack <g...@byoteki.c om 
          >escribió:
          >>
          you've got ?self.send_head er('Server', self.version_st ring()) in the  
          send_response method of the BaseHTTPRequest Handler class in the  
          BaseHTTPServer module. Long story, short, it's going to be a lot of
          >work  
          to get rid of.
          >>
          >One can always write a customized RequestHandler, and just copy the  
          >send_respons e method omiting the offending line. (Ok, you have to check
          >whether it still works with the next Python release... a warning
          >triggered  
          >by a new sys.version would be enough to remember that)
          >
          I see. No choice but to override the method with a copy of the
          source :-/
          I guess I'll have to do with that.
          Another alternative would be to override send_header() and filter out the
          'Server' keyword...

          --
          Gabriel Genellina

          Comment

          Working...