@@ -190,21 +190,39 @@ FTPChannelParent::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
190190{
191191 LOG ((" FTPChannelParent::OnStartRequest [this=%p]\n " , this ));
192192
193- nsFtpChannel* chan = static_cast <nsFtpChannel*>(aRequest);
193+ nsCOMPtr<nsIChannel> chan = do_QueryInterface (aRequest);
194+ MOZ_ASSERT (chan);
195+ NS_ENSURE_TRUE (chan, NS_ERROR_UNEXPECTED );
196+
194197 int64_t contentLength;
195198 chan->GetContentLength (&contentLength);
196199 nsCString contentType;
197200 chan->GetContentType (contentType);
201+
198202 nsCString entityID;
199- chan->GetEntityID (entityID);
200- PRTime lastModified;
201- chan->GetLastModifiedTime (&lastModified);
203+ nsCOMPtr<nsIResumableChannel> resChan = do_QueryInterface (aRequest);
204+ MOZ_ASSERT (resChan); // both FTP and HTTP should implement nsIResumableChannel
205+ if (resChan) {
206+ resChan->GetEntityID (entityID);
207+ }
208+
209+ nsCOMPtr<nsIFTPChannel> ftpChan = do_QueryInterface (aRequest);
210+ PRTime lastModified = 0 ;
211+ if (ftpChan) {
212+ ftpChan->GetLastModifiedTime (&lastModified);
213+ } else {
214+ // Temporary hack: if we were redirected to use an HTTP channel (ie FTP is
215+ // using an HTTP proxy), cancel, as we don't support those redirects yet.
216+ aRequest->Cancel (NS_ERROR_NOT_IMPLEMENTED );
217+ }
202218
203- URIParams uri;
204- SerializeURI (chan->URI (), uri);
219+ URIParams uriparam;
220+ nsCOMPtr<nsIURI> uri;
221+ chan->GetURI (getter_AddRefs (uri));
222+ SerializeURI (uri, uriparam);
205223
206224 if (mIPCClosed || !SendOnStartRequest (contentLength, contentType,
207- lastModified, entityID, uri )) {
225+ lastModified, entityID, uriparam )) {
208226 return NS_ERROR_UNEXPECTED ;
209227 }
210228
0 commit comments