title: HTTP error 304 (Not Modified) exception not returned by python urllib2.request.add_header
body: <p>I was trying to implement handling Last-Modified feature of HTTP using python urllib2 library, so that if server's GET response is not modified since last time it should throw "urllib2.HTTPError: HTTP Error 304: Not Modified". I have implemented the same using below code , but not sure why I am not getting the 304 response. </p>
  
  <p>Also I did research on urllib2.py but not found any detail of status code 304 implementation in this module. </p>
  
  <p>Below is my code and result:</p>
  
  <pre><code>import httplib
  import urllib2
  
  httplib.HTTPConnection.debuglevel = 1
  request = urllib2.Request('http://www.iitg.ac.in/groff/projects.html')
  opener = urllib2.build_opener()
  firstdatastream = opener.open(request)
  print firstdatastream.headers.dict
  request.add_header("If−Modified−Since", firstdatastream.headers.dict['last-   modified'])
  print "Value of last modified time \n"
  var = firstdatastream.headers.dict['last-modified']
  print var 
  seconddatastream = opener.open(request)
  print seconddatastream.headers.dict
  </code></pre>
  
  <p>The second last line of code should raise "urllib2.HTTPError: HTTP Error 304: Not Modified", because of (this line of code ):
      request.add_header("If−Modified−Since", firstdatastream.headers.dict['last-   modified'])</p>
  
  <p>but I am unable to see it on my console result. Below is my result:</p>
  
  <p>{'content-length': '6706', 'accept-ranges': 'none', 'server': 'Apache/2.2.15 (Red Hat)', 'last-modified': 'Thu, 07 May 2015 09:27:08 GMT', 'connection': 'close', 'etag': '"8a0ce0-1a32-5157a83ffe2b7"', 'date': 'Fri, 14 Aug 2015 06:22:02 GMT', 'content-type': 'text/html; charset=UTF-8'}
  Value of last modified time </p>
  
  <p>Thu, 07 May 2015 09:27:08 GMT</p>
  
  <blockquote>
    <blockquote>
      <blockquote>
        <p>{'content-length': '6706', 'accept-ranges': 'none', 'server': 'Apache/2.2.15 (Red Hat)', 'last-modified': 'Thu, 07 May 2015 09:27:08 GMT', 'connection': 'close', 'etag': '"8a0ce0-1a32-5157a83ffe2b7"', 'date': 'Fri, 14 Aug 2015 06:22:02 GMT', 'content-type': 'text/html; charset=UTF-8'}</p>
      </blockquote>
    </blockquote>
  </blockquote>
  
  <p>Any help will be appreciated. Thanks a lot.</p>