2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-19 02:01:16 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-04-19 11:17:37 +04:00
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-04-19 11:17:37 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-04-19 11:17:37 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-19 02:01:16 +04:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-09-29 00:14:13 +04:00
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-19 02:01:16 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-19 02:01:16 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-04-20 12:01:31 +04:00
|
|
|
#include <stdio.h>
|
2001-01-24 01:10:34 +03:00
|
|
|
#include <signal.h>
|
1999-04-29 22:52:14 +04:00
|
|
|
|
1999-05-04 22:50:59 +04:00
|
|
|
#ifdef WIN32
|
1999-04-19 11:17:37 +04:00
|
|
|
#include <windows.h>
|
1999-04-29 22:52:14 +04:00
|
|
|
#endif
|
2000-02-29 18:40:42 +03:00
|
|
|
#ifdef OS2
|
|
|
|
#include <os2.h>
|
|
|
|
#endif
|
1999-04-19 11:17:37 +04:00
|
|
|
|
|
|
|
#include "nspr.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsISocketTransportService.h"
|
|
|
|
#include "nsIEventQueueService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2001-02-21 23:38:08 +03:00
|
|
|
#include "nsITransport.h"
|
|
|
|
#include "nsIRequest.h"
|
2001-01-24 01:10:34 +03:00
|
|
|
#include "nsIStreamProvider.h"
|
1999-04-19 11:17:37 +04:00
|
|
|
#include "nsIStreamListener.h"
|
1999-08-27 14:33:37 +04:00
|
|
|
#include "nsIPipe.h"
|
2000-08-22 11:03:33 +04:00
|
|
|
#include "nsIOutputStream.h"
|
|
|
|
#include "nsIInputStream.h"
|
1999-04-22 12:47:06 +04:00
|
|
|
#include "nsCRT.h"
|
1999-08-27 14:33:37 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2001-01-24 01:10:34 +03:00
|
|
|
#include "nsIByteArrayInputStream.h"
|
|
|
|
|
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
static PRLogModuleInfo *gTestSocketIOLog;
|
|
|
|
#define LOG(args) PR_LOG(gTestSocketIOLog, PR_LOG_DEBUG, args)
|
2001-01-24 02:40:50 +03:00
|
|
|
#else
|
|
|
|
#define LOG(args)
|
|
|
|
#endif
|
1999-04-19 11:17:37 +04:00
|
|
|
|
|
|
|
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
1999-06-02 15:27:07 +04:00
|
|
|
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
1999-04-19 11:17:37 +04:00
|
|
|
|
1999-04-20 12:01:31 +04:00
|
|
|
static PRTime gElapsedTime;
|
1999-04-19 11:17:37 +04:00
|
|
|
static int gKeepRunning = 1;
|
1999-05-06 02:41:44 +04:00
|
|
|
static nsIEventQueue* gEventQ = nsnull;
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Test Listener
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
|
|
|
|
class TestListener : public nsIStreamListener
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
|
|
|
public:
|
2003-01-09 01:35:09 +03:00
|
|
|
TestListener() {}
|
2001-02-21 23:38:08 +03:00
|
|
|
virtual ~TestListener() {}
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2001-04-10 10:01:08 +04:00
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_DECL_NSISTREAMLISTENER
|
1999-04-19 11:17:37 +04:00
|
|
|
};
|
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(TestListener,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsIRequestObserver,
|
2001-02-21 23:38:08 +03:00
|
|
|
nsIStreamListener);
|
2000-02-11 04:52:23 +03:00
|
|
|
|
1999-04-19 11:17:37 +04:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
TestListener::OnStartRequest(nsIRequest* request, nsISupports* context)
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
LOG(("TestListener::OnStartRequest\n"));
|
|
|
|
return NS_OK;
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
TestListener::OnDataAvailable(nsIRequest* request,
|
|
|
|
nsISupports* context,
|
|
|
|
nsIInputStream *aIStream,
|
|
|
|
PRUint32 aSourceOffset,
|
|
|
|
PRUint32 aLength)
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
2001-01-24 01:10:34 +03:00
|
|
|
LOG(("TestListener::OnDataAvailable [offset=%u length=%u]\n",
|
|
|
|
aSourceOffset, aLength));
|
2001-02-21 23:38:08 +03:00
|
|
|
char buf[1025];
|
|
|
|
PRUint32 amt;
|
2001-01-24 01:10:34 +03:00
|
|
|
while (1) {
|
2001-02-21 23:38:08 +03:00
|
|
|
aIStream->Read(buf, 1024, &amt);
|
2001-01-24 01:10:34 +03:00
|
|
|
if (amt == 0)
|
|
|
|
break;
|
2001-02-21 23:38:08 +03:00
|
|
|
buf[amt] = '\0';
|
|
|
|
puts(buf);
|
2001-01-24 01:10:34 +03:00
|
|
|
}
|
2001-02-21 23:38:08 +03:00
|
|
|
return NS_OK;
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
TestListener::OnStopRequest(nsIRequest* request, nsISupports* context,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsresult aStatus)
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
2001-01-24 01:10:34 +03:00
|
|
|
LOG(("TestListener::OnStopRequest [aStatus=%x]\n", aStatus));
|
2001-02-21 23:38:08 +03:00
|
|
|
gKeepRunning = 0;
|
|
|
|
return NS_OK;
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Test Provider
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
class TestProvider : public nsIStreamProvider
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
|
|
|
public:
|
2001-02-21 23:38:08 +03:00
|
|
|
TestProvider(char *data);
|
|
|
|
virtual ~TestProvider();
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2001-04-10 10:01:08 +04:00
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_DECL_NSISTREAMPROVIDER
|
1999-06-08 01:33:30 +04:00
|
|
|
|
1999-04-19 11:17:37 +04:00
|
|
|
protected:
|
2001-02-21 23:38:08 +03:00
|
|
|
nsCOMPtr<nsIByteArrayInputStream> mData;
|
1999-04-19 11:17:37 +04:00
|
|
|
};
|
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(TestProvider,
|
|
|
|
nsIStreamProvider,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsIRequestObserver)
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
TestProvider::TestProvider(char *data)
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_NewByteArrayInputStream(getter_AddRefs(mData), data, strlen(data));
|
|
|
|
LOG(("Constructing TestProvider [this=%x]\n", this));
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
TestProvider::~TestProvider()
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
LOG(("Destroying TestProvider [this=%x]\n", this));
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
TestProvider::OnStartRequest(nsIRequest* request, nsISupports* context)
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
LOG(("TestProvider::OnStartRequest [this=%x]\n", this));
|
|
|
|
return NS_OK;
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
TestProvider::OnStopRequest(nsIRequest* request, nsISupports* context,
|
2001-04-10 10:01:08 +04:00
|
|
|
nsresult aStatus)
|
1999-04-19 11:17:37 +04:00
|
|
|
{
|
2001-01-24 01:10:34 +03:00
|
|
|
LOG(("TestProvider::OnStopRequest [status=%x]\n", aStatus));
|
1999-04-20 12:01:31 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
nsCOMPtr<nsIStreamListener> listener = do_QueryInterface(new TestListener());
|
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
if (NS_SUCCEEDED(aStatus)) {
|
|
|
|
nsCOMPtr<nsITransportRequest> treq = do_QueryInterface(request);
|
|
|
|
nsCOMPtr<nsITransport> transport;
|
|
|
|
treq->GetTransport(getter_AddRefs(transport));
|
|
|
|
if (transport) {
|
|
|
|
nsCOMPtr<nsIRequest> readRequest;
|
|
|
|
transport->AsyncRead(listener, nsnull, 0, 0, 0, getter_AddRefs(readRequest));
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
gKeepRunning = 0;
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
return NS_OK;
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context,
|
|
|
|
nsIOutputStream *output, PRUint32 offset, PRUint32 count)
|
1999-06-22 22:24:02 +04:00
|
|
|
{
|
2001-01-24 01:10:34 +03:00
|
|
|
LOG(("TestProvider::OnDataWritable [offset=%u, count=%u]\n", offset, count));
|
|
|
|
PRUint32 writeCount;
|
|
|
|
nsresult rv = output->WriteFrom(mData, count, &writeCount);
|
|
|
|
// Zero bytes written on success indicates EOF
|
|
|
|
if (NS_SUCCEEDED(rv) && (writeCount == 0))
|
|
|
|
return NS_BASE_STREAM_CLOSED;
|
2001-02-21 23:38:08 +03:00
|
|
|
return rv;
|
1999-06-22 22:24:02 +04:00
|
|
|
}
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Synchronous IO
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
nsresult
|
|
|
|
WriteRequest(nsIOutputStream *os, const char *request)
|
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
LOG(("WriteRequest [request=%s]\n", request));
|
2001-01-24 01:10:34 +03:00
|
|
|
PRUint32 n;
|
|
|
|
return os->Write(request, strlen(request), &n);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ReadResponse(nsIInputStream *is)
|
|
|
|
{
|
|
|
|
PRUint32 bytesRead;
|
|
|
|
char buf[2048];
|
|
|
|
do {
|
|
|
|
is->Read(buf, sizeof(buf), &bytesRead);
|
|
|
|
if (bytesRead > 0)
|
|
|
|
fwrite(buf, 1, bytesRead, stdout);
|
|
|
|
} while (bytesRead > 0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Startup...
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
|
|
|
|
void
|
|
|
|
sighandler(int sig)
|
|
|
|
{
|
|
|
|
LOG(("got signal: %d\n", sig));
|
|
|
|
NS_BREAK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usage(char **argv)
|
|
|
|
{
|
|
|
|
printf("usage: %s [-sync] <host> <path>\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1999-04-19 11:17:37 +04:00
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
nsresult rv;
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
signal(SIGSEGV, sighandler);
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 02:40:50 +03:00
|
|
|
#if defined(PR_LOGGING)
|
2001-01-24 01:10:34 +03:00
|
|
|
gTestSocketIOLog = PR_NewLogModule("TestSocketIO");
|
2001-01-24 02:40:50 +03:00
|
|
|
#endif
|
1999-06-22 22:24:02 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
if (argc < 3)
|
|
|
|
usage(argv);
|
1999-06-22 22:24:02 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
PRIntn i=0;
|
|
|
|
PRBool sync = PR_FALSE;
|
|
|
|
if (nsCRT::strcasecmp(argv[1], "-sync") == 0) {
|
|
|
|
if (argc < 4)
|
|
|
|
usage(argv);
|
|
|
|
sync = PR_TRUE;
|
|
|
|
i = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *hostName = argv[1+i];
|
|
|
|
char *fileName = argv[2+i];
|
|
|
|
int port = 80;
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
// Create the Event Queue for this thread...
|
2001-07-25 11:54:28 +04:00
|
|
|
nsCOMPtr<nsIEventQueueService> eventQService =
|
|
|
|
do_GetService(kEventQueueServiceCID, &rv);
|
2001-01-24 01:10:34 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("failed to create: event queue service!");
|
|
|
|
return rv;
|
|
|
|
}
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
rv = eventQService->CreateMonitoredThreadEventQueue();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("failed to create: thread event queue!");
|
|
|
|
return rv;
|
|
|
|
}
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
// Create the Socket transport service...
|
2001-07-25 11:54:28 +04:00
|
|
|
nsCOMPtr<nsISocketTransportService> sts =
|
|
|
|
do_GetService(kSocketTransportServiceCID, &rv);
|
2001-01-24 01:10:34 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("failed to create: socket transport service!");
|
|
|
|
return rv;
|
|
|
|
}
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
char *buffer = PR_smprintf("GET %s HTTP/1.1" CRLF
|
|
|
|
"host: %s" CRLF
|
|
|
|
"user-agent: Mozilla/5.0 (X11; N; Linux 2.2.16-22smp i686; en-US; m18) Gecko/20001220" CRLF
|
|
|
|
"accept: */*" CRLF
|
|
|
|
"accept-language: en" CRLF
|
|
|
|
"accept-encoding: gzip,deflate,compress,identity" CRLF
|
|
|
|
"keep-alive: 300" CRLF
|
|
|
|
"connection: keep-alive" CRLF
|
|
|
|
CRLF,
|
|
|
|
fileName, hostName);
|
|
|
|
LOG(("Request [\n%s]\n", buffer));
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
// Create the socket transport...
|
|
|
|
nsCOMPtr<nsITransport> transport;
|
2001-09-13 06:21:05 +04:00
|
|
|
rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, getter_AddRefs(transport));
|
2001-01-24 01:10:34 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("failed to create: socket transport!");
|
|
|
|
return rv;
|
2001-02-21 23:38:08 +03:00
|
|
|
}
|
1999-05-09 23:18:25 +04:00
|
|
|
|
1999-04-20 12:01:31 +04:00
|
|
|
gElapsedTime = PR_Now();
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-01-24 01:10:34 +03:00
|
|
|
if (!sync) {
|
2001-02-21 23:38:08 +03:00
|
|
|
nsCOMPtr<nsIRequest> request;
|
|
|
|
rv = transport->AsyncWrite(new TestProvider(buffer), nsnull, 0, 0, 0, getter_AddRefs(request));
|
2001-01-24 01:10:34 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("failed calling: AsyncWrite!");
|
|
|
|
return rv;
|
2001-02-21 23:38:08 +03:00
|
|
|
}
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
// Enter the message pump to allow the URL load to proceed.
|
|
|
|
while ( gKeepRunning ) {
|
|
|
|
PLEvent *gEvent;
|
2003-04-04 20:01:51 +04:00
|
|
|
gEventQ->WaitForEvent(&gEvent);
|
|
|
|
gEventQ->HandleEvent(gEvent);
|
2001-02-21 23:38:08 +03:00
|
|
|
}
|
2001-01-24 01:10:34 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// synchronous write
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIOutputStream> os;
|
2001-02-21 23:38:08 +03:00
|
|
|
rv = transport->OpenOutputStream(0, 0, 0, getter_AddRefs(os));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(("OpenOutputStream failed [rv=%x]\n", rv));
|
|
|
|
return rv;
|
|
|
|
}
|
2001-01-24 01:10:34 +03:00
|
|
|
rv = WriteRequest(os, buffer);
|
2001-02-21 23:38:08 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(("WriteRequest failed [rv=%x]\n", rv));
|
|
|
|
return rv;
|
|
|
|
}
|
2001-01-24 01:10:34 +03:00
|
|
|
}
|
|
|
|
// synchronous read
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIInputStream> is;
|
2001-02-21 23:38:08 +03:00
|
|
|
rv = transport->OpenInputStream(0, 0, 0, getter_AddRefs(is));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(("OpenInputStream failed [rv=%x]\n", rv));
|
|
|
|
return rv;
|
|
|
|
}
|
2001-01-24 01:10:34 +03:00
|
|
|
rv = ReadResponse(is);
|
2001-02-21 23:38:08 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(("ReadResponse failed [rv=%x]\n", rv));
|
|
|
|
return rv;
|
|
|
|
}
|
2001-01-24 01:10:34 +03:00
|
|
|
}
|
|
|
|
}
|
1999-04-19 11:17:37 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
PRTime endTime;
|
|
|
|
endTime = PR_Now();
|
2001-01-24 01:10:34 +03:00
|
|
|
LOG(("Elapsed time: %d\n", (PRInt32)(endTime/1000UL - gElapsedTime/1000UL)));
|
1999-04-20 12:01:31 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
sts->Shutdown();
|
|
|
|
return 0;
|
1999-04-19 11:17:37 +04:00
|
|
|
}
|
2001-02-21 23:38:08 +03:00
|
|
|
|