Author: jbevain
Date: 2007-11-07 05:03:54 -0500 (Wed, 07 Nov 2007)
New Revision: 89081
Modified:
trunk/moon/plugin/ChangeLog
trunk/moon/plugin/browser-http.cpp
trunk/moon/plugin/browser-http.h
Log:
2007-11-07 Jb Evain <[EMAIL PROTECTED]>
* browser-http.cpp|h: implement a GetStatus method for
BrowserHttpResponse.
Modified: trunk/moon/plugin/ChangeLog
===================================================================
--- trunk/moon/plugin/ChangeLog 2007-11-07 10:02:45 UTC (rev 89080)
+++ trunk/moon/plugin/ChangeLog 2007-11-07 10:03:54 UTC (rev 89081)
@@ -1,3 +1,8 @@
+2007-11-07 Jb Evain <[EMAIL PROTECTED]>
+
+ * browser-http.cpp|h: implement a GetStatus method for
+ BrowserHttpResponse.
+
2007-11-06 Miguel de Icaza <[EMAIL PROTECTED]>
* plugin.cpp (string_to_js): rename from escape_quotes, this helps
Modified: trunk/moon/plugin/browser-http.cpp
===================================================================
--- trunk/moon/plugin/browser-http.cpp 2007-11-07 10:02:45 UTC (rev 89080)
+++ trunk/moon/plugin/browser-http.cpp 2007-11-07 10:03:54 UTC (rev 89081)
@@ -33,8 +33,8 @@
this->handler (name, val);
- g_free ((gpointer) name);
- g_free ((gpointer) val);
+ // g_free ((gpointer) name);
+ // g_free ((gpointer) val);
return NS_OK;
}
@@ -53,6 +53,30 @@
this->handler = NULL;
}
+char *
+BrowserHttpResponse::GetStatus (int *code)
+{
+ nsCOMPtr<nsIHttpChannel> httpchannel = do_QueryInterface (channel);
+ if (!httpchannel) {
+ *code = 0;
+ return NULL;
+ }
+
+ nsEmbedCString status_desc;
+ PRUint32 status;
+ const char *desc;
+ int dl;
+
+ httpchannel->GetResponseStatusText (status_desc);
+
+ dl = NS_CStringGetData (status_desc, &desc);
+
+ httpchannel->GetResponseStatus (&status);
+
+ *code = status;
+ return g_strndup (desc, dl);
+}
+
// SyncBrowserHttpResponse
void *
@@ -99,7 +123,6 @@
NS_IMETHODIMP
AsyncBrowserHttpResponse::OnStopRequest (nsIRequest *request, nsISupports
*ctx, nsresult status)
{
- // TODO: check the status, and store it in the response
handler (this, this->context);
return NS_OK;
}
@@ -189,7 +212,9 @@
void
BrowserHttpRequest::GetAsyncResponse (AsyncResponseAvailableHandler handler,
gpointer context)
{
- AsyncBrowserHttpResponse *response = new AsyncBrowserHttpResponse
(channel, handler, context);
+ AsyncBrowserHttpResponse *response;
+
+ response = new AsyncBrowserHttpResponse (channel, handler, context);
channel->AsyncOpen (response, (BrowserHttpResponse *) response);
}
@@ -279,6 +304,12 @@
response->VisitHeaders (handler);
}
+char *
+browser_http_response_get_status (BrowserHttpResponse *response, int *code)
+{
+ return response->GetStatus (code);
+}
+
void
browser_http_response_destroy (BrowserHttpResponse *response)
{
Modified: trunk/moon/plugin/browser-http.h
===================================================================
--- trunk/moon/plugin/browser-http.h 2007-11-07 10:02:45 UTC (rev 89080)
+++ trunk/moon/plugin/browser-http.h 2007-11-07 10:03:54 UTC (rev 89081)
@@ -57,6 +57,7 @@
}
void VisitHeaders (HttpHeaderHandler handler);
+ char *GetStatus (int *code);
virtual void *Read (int *length) = 0;
};
@@ -151,6 +152,7 @@
void browser_http_request_get_async_response (BrowserHttpRequest *request,
AsyncResponseAvailableHandler handler, gpointer context);
void *browser_http_response_read (BrowserHttpResponse *response, int *size);
void browser_http_response_visit_headers (BrowserHttpResponse *response,
HttpHeaderHandler handler);
+char *browser_http_response_get_status (BrowserHttpResponse *response, int
*code);
void browser_http_response_destroy (BrowserHttpResponse *response);
#if BROWSER_HTTP_TEST
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches