The code below is taken from
ingoingFilter
in
HTTPQoS
Line 1 detects if the request has in input stream to measure. Line 3 creates an instance of
PipedOutputStream named
pout
. Line 4 creates an instance of
PipedInputStream
,
pin
to
which
pout
is passed as a parameter. This effectively means that whatever is fed to
pout
will
automatically be passed to
pin
.
HTTPQoS.java
1. if(request.hasOutputStream()){
2. try {
3. PipedOutputStream pout = new PipedOutputStream();
4. PipedInputStream pin = new PipedInputStream(pout);
5. new RequestDataMover(request.getOutputStream(),pout,myQOSParameters);
6. request.setOutputStream(pin);
7. }
8. catch (Exception ex) {}
9. }
10.
}
In line 5 a new instance of
RequestDataMover
in instantiated, the constructor of which is
passed the current requests input stream, the instance of PipedOutputStream
pout
and an
instance of
QoSParameters
. Finally in line 6, the requests output stream is passed
pin
. What
this effectively allows is to monitor the request's output stream without interrupting it as it is
passed to the target server. The implication of this are that the time data flows can be
measured as can the amount of data transferred to the server. Additionally since the
RequestDataMover
is threaded it does not cause the filter to block.
a
a
c