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 java.util.ArrayList;
14 import java.util.List;
16 import net.sourceforge.phpdt.monitor.core.IMonitor;
17 import net.sourceforge.phpdt.monitor.core.IRequest;
18 import net.sourceforge.phpdt.monitor.core.internal.Request;
19 import net.sourceforge.phpdt.monitor.core.internal.Trace;
21 * Manages a monitor server connection between two hosts. This
22 * connection may spawn one or more TCP/IP pairs to be displayed
23 * in the monitor server view.
25 public class HTTPConnection {
26 protected IMonitor monitor;
28 protected int req = -1;
29 protected int resp = -1;
31 protected List calls = new ArrayList();
34 * MonitorHTTPConnection constructor comment.
36 public HTTPConnection(IMonitor monitor) {
38 this.monitor = monitor;
39 Trace.trace(Trace.PARSING, "TCP/IP monitor connection opened " + monitor);
45 * @param isNew boolean
47 public void addRequest(byte[] request, boolean isNew) {
50 Request pair = (Request) getRequestResponse(req);
51 pair.addToRequest(request);
57 * @param isNew boolean
59 public void addResponse(byte[] response, boolean isNew) {
62 Request pair = (Request) getRequestResponse(resp);
63 pair.addToResponse(response);
69 public void addProperty(String key, Object value) {
70 IRequest pair = getRequestResponse(req);
71 pair.addProperty(key, value);
77 public IRequest getRequestResponse(boolean isRequest) {
79 return getRequestResponse(req);
81 return getRequestResponse(resp);
87 protected IRequest getRequestResponse(int i) {
89 while (i >= calls.size()) {
90 Request rr = new HTTPRequest(monitor.getLocalPort(), monitor.getRemoteHost(), monitor.getRemotePort());
94 return (Request) calls.get(i);
101 * @param isNew boolean
103 public void setLabel(String title, boolean isNew) {
106 Request pair = (Request) getRequestResponse(req);
107 pair.setLabel(title);