Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:57:02+00:00 2026-06-11T08:57:02+00:00

Server setup and browser checking from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class customHTTPServer(BaseHTTPRequestHandler): def do_GET(self):

  • 0

Server setup and browser checking

from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class customHTTPServer(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        self.wfile.write('<HTML><body>Get!</body></HTML>')
        return

server = HTTPServer(('',8080),customHTTPServer)
print 'server started at port 8080'
server.serve_forever()

Now when I go to http://localhost:8080 with my browser I can see the expected Get!.

Unexpected observations

Test 1:

Now I tested using different status codes in my server. I tried these status codes: 301, 302, 400, 402, 403, 404, 405, 406, 407, 408, 418, 500, 501, 502, 504, 505 and 511.

(Q1) Strangely when using different status codes(except for 407) I get the same behavior as I was using status code 200. Why is that?

Test 2

Secondly I replaced self.wfile.write('<HTML><body>Get!</body></HTML>')
with self.wfile.write('') for all the different status codes I tested in the 1st test. When I used status code 403, 404, 500, 501, 502, 504 or 505 I now got a specific browser message on the browser (403 Forbidden, 404 not found, …).

(Q2) Why do I only receive specific browser messages using these status codes but while not using the other ones?

Summary

I can distinquish 3 types of behavior:

  • Using status code 301, 302, 400, 402, 405, 406, 408, 418 or 511 has
    no difference with using status code 200 regardless if I am sending an empty or non-empty string.
  • Using status code 403, 404, 500, 501, 502, 504 or 505 will create a specific browser message on the browser but only when an empty string is
    sent.
  • Using status code 407 returns a specific browser message(showing a 323 error) regardless if I am sending an empty or non-empty string.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:57:03+00:00Added an answer on June 11, 2026 at 8:57 am

    (A1) When you send error codes but return a body anyways, the browser will assume it is a custom error page sent by your webserver. This is the way that for example stackoverflow gives you a custom page for requests of unknown documents, instead of the default browserpage for 404.

    (A2) Check the meaning of the statuscodes in which no browser message is displayed and ask yourself if it’s sensible to show a browser message when they are returned. Also, most likely, it will differ from browser to browser when messages are displayed or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just setup a LAMP development server and am still trouble-shooting some things. The
I have reccently setup Hg on my server and my hgweb.config contains this: [paths]
Question I setup Hudson CI on a Windows 2008 server and now I want
I'm attempting to setup svn on my home network on an Ubuntu server box.
I started a new project in rails and setup a server and assembla to
Hi stackoverflow users. My server setup is the following: A webserver with access on
After hours of trying to setup subdomains on my dedicated root server, I'm asking
after deploying my web app to a new server using the add web setup
I'm trying to setup Flash Media Server with an external Apache in order to
I'm trying to get an Apache server running on my Cygwin setup to follow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.