code: public ActionContext applyContentType(Result result) {
          if (!result.status().isError()) {
              return applyContentType();
          }
          return applyContentType(contentTypeForErrorResult(req()));
      }
docs: Apply content type to response with result provided.
  
  If `result` is an error then it might not apply content type as requested:
  * If request is not ajax request, then use `text/html`
  * If request is ajax request then apply requested content type only when `json` or `xml` is requested
  * otherwise use `text/html`
  
  @param result
  the result used to check if it is error result
  @return this `ActionContext`.