Checkpoint. Still waiting for advice on how to get POST inspection working.

M src_moz/EmbedProgress.cpp

- remove PageInfoListener meta-data from END_DOCUMENT_LOAD.  Didn't
  belong there.

M test/manual/src/classes/org/mozilla/webclient/test/TestBrowser.java

- print out the request method and response code.
This commit is contained in:
edburns%acm.org 2005-03-01 20:39:23 +00:00
parent 317cd84a58
commit 1500a6792b
2 changed files with 39 additions and 61 deletions

View File

@ -158,67 +158,6 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
(aStateFlags & STATE_STOP)) {
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("EmbedProgress::OnStateChange: END_DOCUMENT_LOAD\n"));
if (channel && mCapturePageInfo) {
// store the request method
if (NS_SUCCEEDED(rv = channel->GetRequestMethod(cstr))) {
jstring methodJStr = (jstring) ::util_NewGlobalRef(env,
::util_NewStringUTF(env, cstr.get()));
::util_StoreIntoPropertiesObject(env, properties,
METHOD_VALUE, methodJStr,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
// store the response status
PRUint32 responseStatus;
if (NS_SUCCEEDED(rv =channel->GetResponseStatus(&responseStatus))){
if (NS_SUCCEEDED(rv=channel->GetResponseStatusText(cstr))) {
nsAutoString autoStatus;
autoStatus.AppendInt(responseStatus);
autoStatus.AppendWithConversion(" ");
autoStatus.AppendWithConversion(cstr.get());
jstring statusJStr = (jstring) ::util_NewGlobalRef(env,
::util_NewString(env, autoStatus.get(), autoStatus.Length()));
::util_StoreIntoPropertiesObject(env, properties,
STATUS_VALUE, statusJStr,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
}
// If there is an upload stream, store it as well
nsCOMPtr<nsIUploadChannel> upload = do_QueryInterface(channel);
if (upload) {
nsIInputStream *uploadStream = nsnull;
if (NS_SUCCEEDED(rv = upload->GetUploadStream(&uploadStream))
&& uploadStream) {
jint pStream;
jclass clazz;
jobject streamObj;
jmethodID jID;
pStream = (jint) uploadStream;
uploadStream->AddRef();
if (clazz = env->FindClass("org/mozilla/webclient/impl/wrapper_native/NativeInputStream")) {
if (jID = env->GetMethodID(clazz, "<init>", "(I)V")) {
if (streamObj = env->NewObject(clazz,jID,pStream)){
if (streamObj = ::util_NewGlobalRef(env,
streamObj)){
::util_StoreIntoPropertiesObject(env,
properties,
REQUEST_BODY_VALUE,
streamObj,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
}
}
}
}
}
}
util_SendEventToJava(nsnull,
mEventRegistration,
@ -304,6 +243,36 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
}
}
// If there is an upload stream, store it as well
nsCOMPtr<nsIUploadChannel> upload = do_QueryInterface(channel);
if (upload) {
nsIInputStream *uploadStream = nsnull;
if (NS_SUCCEEDED(rv = upload->GetUploadStream(&uploadStream))
&& uploadStream) {
jint pStream;
jclass clazz;
jobject streamObj;
jmethodID jID;
pStream = (jint) uploadStream;
uploadStream->AddRef();
if (clazz = env->FindClass("org/mozilla/webclient/impl/wrapper_native/NativeInputStream")) {
if (jID = env->GetMethodID(clazz, "<init>", "(I)V")) {
if (streamObj = env->NewObject(clazz,jID,pStream)){
if (streamObj = ::util_NewGlobalRef(env,
streamObj)){
::util_StoreIntoPropertiesObject(env,
properties,
REQUEST_BODY_VALUE,
streamObj,
(jobject)
&(mOwner->GetWrapperFactory()->shareContext));
}
}
}
}
}
}
}
util_SendEventToJava(nsnull,

View File

@ -222,8 +222,11 @@ public class TestBrowser extends JPanel {
public void eventDispatched(WebclientEvent event) {
Map map = (Map) event.getEventData();
if (event instanceof DocumentLoadEvent) {
System.out.println("URI: " + map.get("URI"));
switch ((int) event.getType()) {
case ((int) DocumentLoadEvent.START_URL_LOAD_EVENT_MASK):
System.out.println("requestMethod: " +
map.get("method"));
if (map.get("headers") instanceof Map) {
Iterator iter = (map = (Map) map.get("headers")).keySet().iterator();
while (iter.hasNext()) {
@ -239,6 +242,8 @@ public class TestBrowser extends JPanel {
updateStatusInfo("Loading started.");
break;
case ((int) DocumentLoadEvent.END_DOCUMENT_LOAD_EVENT_MASK):
System.out.println("requestMethod: " +
map.get("method"));
jBackButton.setEnabled(history.canBack());
jForwardButton.setEnabled(history.canForward());
updateStatusInfo("Loading completed.");
@ -248,6 +253,10 @@ public class TestBrowser extends JPanel {
}
break;
case ((int) DocumentLoadEvent.END_URL_LOAD_EVENT_MASK):
System.out.println("requestMethod: " +
map.get("method"));
System.out.println("status: " +
map.get("status"));
if (map.get("headers") instanceof Map) {
Iterator iter = (map = (Map) map.get("headers")).keySet().iterator();
while (iter.hasNext()) {