title: In Java, how to set the header of a Restlet Response?
body: <p>I can't seem to figure out how to add headers to my restlet response. When I look at the available methods in the <code>Response</code> object, all I see is <code>setStatus</code>, <code>setEntity</code>, and <code>setAttributes</code> but none of these tell me how to set custom http headers on the response.</p>
  
  <p>For example, I have a <code>GET</code> call the returns something like the following:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Content-Type: text/json
  Content-Length: 123
  Some-Header: the value
  Some-Other-Header: another value
  
  {
    id: 111,
    value: "some value this could be anything",
    diagnosis: {
      start: 12552255,
      end: 12552261,
      key: "ABC123E11",
      source: "S1",
    }
  }
  </code></pre>
  
  <p>Whatever it maybe. In the <code>handleGet</code> method, I handle it like so:</p>
  
  <pre><code>final MediaType textJsonType = new MediaType("text/json");
  
  @Override
  public void handleGet() {
    log.debug("Handling GET...");
    final Response res = this.getResponse();
  
    try {
      final MyObject doc = this.getObj("hello", 1, "ABC123E11", "S1");
      final String docStr = doc.toString();
  
      res.setStatus(Status.SUCCESS_OK);
      res.setEntity(docStr, textJsonType);
  
      // need to set Some-header, and Some-other-header here!
    }
    catch(Throwable t) {
      res.setStatus(Status.SERVER_ERROR_INTERNAL);
      res.setEntity(new TextRepresentation(t.toString()));
    }
  }
  </code></pre>