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.MonitorCore;
14 import net.sourceforge.phpdt.monitor.core.internal.Request;
19 public class HTTPRequest extends Request {
20 protected static final String HTTP_REQUEST_HEADER = "request-header";
21 protected static final String HTTP_RESPONSE_HEADER = "response-header";
23 protected static final String HTTP_REQUEST_BODY = "request-body";
24 protected static final String HTTP_RESPONSE_BODY = "response-body";
26 protected static final byte[] EMPTY = new byte[0];
29 * HTTPRequestResponse constructor comment.
31 public HTTPRequest(int localPort, String remoteHost, int remotePort) {
32 super(MonitorCore.getProtocolAdapter(MonitorCore.HTTP_PROTOCOL_ID), localPort, remoteHost, remotePort);
35 public byte[] getRequest(byte type2) {
38 else if (type2 == TRANSPORT)
39 return getRequestHeader();
41 return getRequestContent();
44 public byte[] getResponse(byte type2) {
47 else if (type2 == TRANSPORT)
48 return getResponseHeader();
50 return getResponseContent();
53 protected byte[] getRequestHeader() {
54 Object obj = getObjectProperty(HTTP_REQUEST_HEADER);
55 if (obj == null || !(obj instanceof byte[]))
61 protected byte[] getRequestContent() {
62 Object obj = getObjectProperty(HTTP_REQUEST_BODY);
63 if (obj == null || !(obj instanceof byte[]))
69 protected byte[] getResponseHeader() {
70 Object obj = getObjectProperty(HTTP_RESPONSE_HEADER);
71 if (obj == null || !(obj instanceof byte[]))
77 protected byte[] getResponseContent() {
78 Object obj = getObjectProperty(HTTP_RESPONSE_BODY);
79 if (obj == null || !(obj instanceof byte[]))