/********************************************************************** * Copyright (c) 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html  * * Contributors: * IBM - Initial API and implementation **********************************************************************/ package net.sourceforge.phpdt.monitor.core.internal.http; import net.sourceforge.phpdt.monitor.core.MonitorCore; import net.sourceforge.phpdt.monitor.core.internal.Request; /** * */ public class HTTPRequest extends Request { protected static final String HTTP_REQUEST_HEADER = "request-header"; protected static final String HTTP_RESPONSE_HEADER = "response-header"; protected static final String HTTP_REQUEST_BODY = "request-body"; protected static final String HTTP_RESPONSE_BODY = "response-body"; protected static final byte[] EMPTY = new byte[0]; /** * HTTPRequestResponse constructor comment. */ public HTTPRequest(int localPort, String remoteHost, int remotePort) { super(MonitorCore.getProtocolAdapter(MonitorCore.HTTP_PROTOCOL_ID), localPort, remoteHost, remotePort); } public byte[] getRequest(byte type2) { if (type2 == ALL) return request; else if (type2 == TRANSPORT) return getRequestHeader(); else return getRequestContent(); } public byte[] getResponse(byte type2) { if (type2 == ALL) return response; else if (type2 == TRANSPORT) return getResponseHeader(); else return getResponseContent(); } protected byte[] getRequestHeader() { Object obj = getObjectProperty(HTTP_REQUEST_HEADER); if (obj == null || !(obj instanceof byte[])) return null; else return (byte[]) obj; } protected byte[] getRequestContent() { Object obj = getObjectProperty(HTTP_REQUEST_BODY); if (obj == null || !(obj instanceof byte[])) return null; else return (byte[]) obj; } protected byte[] getResponseHeader() { Object obj = getObjectProperty(HTTP_RESPONSE_HEADER); if (obj == null || !(obj instanceof byte[])) return null; else return (byte[]) obj; } protected byte[] getResponseContent() { Object obj = getObjectProperty(HTTP_RESPONSE_BODY); if (obj == null || !(obj instanceof byte[])) return null; else return (byte[]) obj; } }