code: private void handleConnectionProperties(URLConnection conn)
      {
          if (pageProperties == null)
          {
              pageProperties = new Hashtable<String, Object>(22);
          }
  
          String type = conn.getContentType();
          if (type != null)
          {
              // XXX mozno prepisat podla seba, setContentType, len pre text/****
              setContentType(type); // >> XXX putClientProperty("charset",
                                    // charset); !!!
              // charset\s*=[\s'"]*([\-_a-zA-Z0-9]+)[\s'",;]*
              // pageProperties.put("content-type", type);
          }
  
          pageProperties.put(Document.StreamDescriptionProperty, conn.getURL());
  
          // String enc = conn.getContentEncoding();
          // if (enc != null) {
          // pageProperties.put("content-encoding", enc);
          // }
  
          Map<String, List<String>> header = conn.getHeaderFields();
  
          Set<String> keys = header.keySet();
          Object obj;
          for (String key : keys)
          {
              obj = header.get(key);
              if (key != null && obj != null)
              {
                  pageProperties.put(key, obj);
              }
          }
  
          System.out.println("# pageProperties #");
          for (String k : pageProperties.keySet())
          {
              System.out.println(k + " : " + pageProperties.get(k));
          }
  
      }
docs: Handle URL connection properties (most notably, content type).