1 /**********************************************************************
2 * Copyright (c) 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM - Initial API and implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.monitor.core.internal.http;
13 import net.sourceforge.phpdt.monitor.core.IMonitor;
14 import net.sourceforge.phpdt.monitor.core.IRequest;
15 import net.sourceforge.phpdt.monitor.core.internal.Request;
16 import net.sourceforge.phpdt.monitor.core.internal.Trace;
19 import java.util.List;
20 import java.util.ArrayList;
22 * Manages a monitor server connection between two hosts. This
23 * connection may spawn one or more TCP/IP pairs to be displayed
24 * in the monitor server view.
26 public class HTTPConnection {
27 protected IMonitor monitor;
29 protected int req = -1;
30 protected int resp = -1;
32 protected List calls = new ArrayList();
35 * MonitorHTTPConnection constructor comment.
37 public HTTPConnection(IMonitor monitor) {
39 this.monitor = monitor;
40 Trace.trace(Trace.PARSING, "TCP/IP monitor connection opened " + monitor);
46 * @param isNew boolean
48 public void addRequest(byte[] request, boolean isNew) {
51 Request pair = (Request) getRequestResponse(req);
52 pair.addToRequest(request);
58 * @param isNew boolean
60 public void addResponse(byte[] response, boolean isNew) {
63 Request pair = (Request) getRequestResponse(resp);
64 pair.addToResponse(response);
70 public void addProperty(String key, Object value) {
71 IRequest pair = getRequestResponse(req);
72 pair.addProperty(key, value);
78 public IRequest getRequestResponse(boolean isRequest) {
80 return getRequestResponse(req);
82 return getRequestResponse(resp);
88 protected IRequest getRequestResponse(int i) {
90 while (i >= calls.size()) {
91 Request rr = new HTTPRequest(monitor.getLocalPort(), monitor.getRemoteHost(), monitor.getRemotePort());
95 return (Request) calls.get(i);
102 * @param isNew boolean
104 public void setLabel(String title, boolean isNew) {
107 Request pair = (Request) getRequestResponse(req);
108 pair.setLabel(title);