<commit_before>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.nanos.http;

import foam.core.*;
import foam.dao.*;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;

@SuppressWarnings("serial")
public class WebAgentServlet
  extends    HttpServlet
  implements ContextAware
{
  protected WebAgent agent_;
  protected X        x_;

  public WebAgentServlet(WebAgent agent) {
    agent_ = agent;
  }

  public X    getX()    { return x_; }
  public void setX(X x) { x_ = x; }

  @Override
  public void service(HttpServletRequest req, HttpServletResponse resp)
    throws IOException
  {
    agent_.execute(getX().put(req.getClass(), req).put(resp.getClass(), resp).put(PrintWriter.class, resp.getWriter()));
  }
}<commit_msg>Set default content type to text/html for WebAgents.<commit_after>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.nanos.http;

import foam.core.*;
import foam.dao.*;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;

@SuppressWarnings("serial")
public class WebAgentServlet
  extends    HttpServlet
  implements ContextAware
{
  protected WebAgent agent_;
  protected X        x_;

  public WebAgentServlet(WebAgent agent) {
    agent_ = agent;
  }

  public X    getX()    { return x_; }
  public void setX(X x) { x_ = x; }

  @Override
  public void service(HttpServletRequest req, HttpServletResponse resp)
    throws IOException
  {
    resp.setContentType("text/html");

    agent_.execute(getX().put(req.getClass(), req).put(resp.getClass(), resp).put(PrintWriter.class, resp.getWriter()));
  }
}
{'fraction_non_alphanumeric': 0.11613216715257532, 'fraction_numerical': 0.0058309037900874635, 'mean_word_length': 4.173366834170854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5988490', 'n_tokens_mistral': 617, 'n_tokens_neox': 622, 'n_words': 152}