<commit_before>package org.squbs.httpclient.pipeline

import akka.actor._
import akka.pattern._
import org.squbs.pipeline.{RequestContext, PipeLineMgr}
import org.squbs.proxy.{SimplePipeLineConfig, SimpleProcessor}
import spray.client.pipelining.SendReceive
import spray.http.{ChunkedRequestStart, HttpRequest, HttpResponse}

/**
 * Created by jiamzhang on 2015/3/6.
 */
class HttpClientPipeLineActor(pipelineConf: SimplePipeLineConfig, target: SendReceive) extends Actor with ActorLogging {

	override def receive = {
		case request: HttpRequest =>
			val responder = sender()
			val targetAgent = context.actorOf(Props(classOf[HttpClientPipeLineTargetActor], target))
			val pipeproxy = PipeLineMgr(context.system).getPipeLine(new SimpleProcessor((pipelineConf)), targetAgent, responder)
			pipeproxy ! RequestContext(request)

		case request: ChunkedRequestStart =>
			val responder = sender()
			val targetAgent = context.actorOf(Props(classOf[HttpClientPipeLineTargetActor], target))
			val pipeproxy = PipeLineMgr(context.system).getPipeLine(new SimpleProcessor((pipelineConf)), targetAgent, responder)
			pipeproxy ! RequestContext(request.request, true)

	}
}

class HttpClientPipeLineTargetActor(target: SendReceive) extends Actor with ActorLogging {
	import context._
	private var client: ActorRef = ActorRef.noSender

	override def receive = {
		case request: HttpRequest =>
			client = sender()
			target(request) pipeTo self

		case response: HttpResponse =>
			client ! response
	}
}<commit_msg>Add context stop when one call is done.<commit_after>package org.squbs.httpclient.pipeline

import akka.actor._
import akka.pattern._
import org.squbs.httpclient.endpoint.Endpoint
import org.squbs.pipeline.{RequestContext, PipeLineMgr}
import org.squbs.proxy.{SimplePipeLineConfig, SimpleProcessor}
import spray.client.pipelining.SendReceive
import spray.http.{ChunkedRequestStart, HttpRequest, HttpResponse}

/**
 * Created by jiamzhang on 2015/3/6.
 */
class HttpClientPipeLineActor(endpoint: Endpoint, pipelineConf: SimplePipeLineConfig, target: SendReceive) extends Actor with ActorLogging {

	override def receive = {
		case request: HttpRequest =>
			val responder = sender()
			val targetAgent = context.actorOf(Props(classOf[HttpClientPipeLineTargetActor], target))
			val pipeproxy = PipeLineMgr(context.system).getPipeLine(new SimpleProcessor((pipelineConf)), targetAgent, responder)
			pipeproxy ! RequestContext(request)
			context.stop(self)

		case request: ChunkedRequestStart =>
			val responder = sender()
			val targetAgent = context.actorOf(Props(classOf[HttpClientPipeLineTargetActor], target))
			val pipeproxy = PipeLineMgr(context.system).getPipeLine(new SimpleProcessor((pipelineConf)), targetAgent, responder)
			pipeproxy ! RequestContext(request.request, true)
			context.stop(self)
	}
}

class HttpClientPipeLineTargetActor(target: SendReceive) extends Actor with ActorLogging {
	import context._
	private var client: ActorRef = ActorRef.noSender

	override def receive = {
		case request: HttpRequest =>
			client = sender()
			target(request) pipeTo self

		case response: HttpResponse =>
			client ! response
			context.stop(self)
	}
}
{'fraction_non_alphanumeric': 0.09196850393700787, 'fraction_numerical': 0.003779527559055118, 'mean_word_length': 5.80085653104925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1798234', 'n_tokens_mistral': 1010, 'n_tokens_neox': 921, 'n_words': 218}