[XForms] Generate xforms-submit-error on HTTP error responses. Bug 310125, r=doronr+smaug

This commit is contained in:
allan%beaufour.dk 2006-05-30 14:56:57 +00:00
Родитель eb6031d72d
Коммит a42bfe8317
1 изменённых файлов: 35 добавлений и 22 удалений

Просмотреть файл

@ -391,30 +391,42 @@ nsXFormsSubmissionElement::OnChannelRedirect(nsIChannel *aOldChannel,
}
NS_IMETHODIMP
nsXFormsSubmissionElement::OnStartRequest(nsIRequest *request, nsISupports *ctx)
nsXFormsSubmissionElement::OnStartRequest(nsIRequest *aRequest,
nsISupports *aCtx)
{
return NS_OK;
}
NS_IMETHODIMP
nsXFormsSubmissionElement::OnStopRequest(nsIRequest *request, nsISupports *ctx, nsresult status)
nsXFormsSubmissionElement::OnStopRequest(nsIRequest *aRequest,
nsISupports *aCtx,
nsresult aStatus)
{
LOG(("xforms submission complete [status=%x]\n", status));
LOG(("xforms submission complete [status=%x]\n", aStatus));
if (!mElement) {
return NS_OK;
}
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
NS_ASSERTION(channel, "request should be a channel");
PRBool succeeded = NS_SUCCEEDED(status);
if (succeeded)
{
PRBool succeeded = NS_SUCCEEDED(aStatus);
if (succeeded) {
// If it is a HTTP request, then check for error responses, which should
// result in NOP and an xforms-submit-error.
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
if (httpChannel) {
PRUint32 response;
nsresult rv = httpChannel->GetResponseStatus(&response);
succeeded = NS_SUCCEEDED(rv) && (response < 400);
}
if (succeeded) {
PRUint32 avail = 0;
mPipeIn->Available(&avail);
if (avail > 0)
{
if (avail > 0) {
nsresult rv;
if (mIsReplaceInstance) {
@ -430,6 +442,7 @@ nsXFormsSubmissionElement::OnStopRequest(nsIRequest *request, nsISupports *ctx,
succeeded = NS_SUCCEEDED(rv);
}
}
}
mPipeIn = 0;