示例#1
0
        public NetResponse pushMultipartData(String strUrl, MultipartItem oItem, IRhoSession oSession, Hashtable <String, String> pHeaders)
        {
            Vector <MultipartItem> arItems = new Vector <MultipartItem>();

            arItems.addElement(oItem);

            return(pushMultipartData(strUrl, arItems, oSession, pHeaders));
        }
示例#2
0
        public NetResponse pushData(String strUrl, String strBody, IRhoSession oSession)
        {
            m_bCancel = false;

            if (RHODESAPP().isRhodesAppUrl(strUrl))
            {
                return(RHODESAPP().processCallback(strUrl, strBody));
            }

            return(doRequest("POST", strUrl, strBody, oSession, null));
        }
示例#3
0
 void handleCookie(IRhoSession oSession)
 {
     if (oSession != null)
     {
         String strSession = oSession.getSession();
         LOG.INFO("Cookie : " + (strSession != null ? strSession : ""));
         if (strSession != null && strSession.length() > 0 && !strSession.equals("rho_empty"))
         {
             m_webRequest.CookieContainer.SetCookies(new Uri(m_strUrl), strSession);
         }
     }
 }
示例#4
0
        public NetResponse doRequest(String strMethod, String strUrl, String strBody, IRhoSession oSession, Hashtable <String, String> headers)
        {
            m_respWaitEvent.WaitOne();
            m_respWaitEvent.Reset();


            m_oSession = oSession;
            m_strBody  = strBody;
            m_strUrl   = strUrl;
            m_headers  = headers;

            m_bCancel = false;

            m_webRequest = WebRequest.Create(strUrl) as HttpWebRequest;
            LOG.INFO("connection done");

            m_webRequest.CookieContainer = new CookieContainer();
            handleCookie(oSession);

            if (strBody != null && strBody.length() > 0)
            {
                if (oSession != null)
                {
                    m_webRequest.ContentType = oSession.getContentType();
                }
                else
                {
                    m_webRequest.ContentType = "application/x-www-form-urlencoded";
                }

                writeHeaders(headers);
                LOG.INFO("writeHeaders done");
                m_webRequest.Method = strMethod;

                m_webRequest.BeginGetRequestStream(GetRequestStreamCallback, null);
                m_reqWaitEvent.Reset();
                m_reqWaitEvent.WaitOne();
            }
            else
            {
                writeHeaders(headers);
                m_webRequest.Method = strMethod;
            }

            m_webRequest.BeginGetResponse(GetResponseCallback, null);
            m_respWaitEvent.Reset();
            m_respWaitEvent.WaitOne();

            return(makeResponse(m_strRespBody, m_code));
        }
示例#5
0
        public NetResponse pullFile(String strUrl, String strFileName, IRhoSession oSession, Hashtable <String, String> headers)
        {
            NetResponse resp = null;

            m_isPullFile = true;

            m_bCancel = false;

            try{
                if (!strFileName.startsWith("file:"))
                {
                    try{
                        strFileName = CFilePath.join(CRhodesApp.getRhoRootPath(), strFileName);
                    } catch (IOException e) {
                        LOG.ERROR("getDirPath failed.", e);
                    }
                }

                m_pulledFile = RhoClassFactory.createFile();
                m_pulledFile.open(strFileName, CRhoFile.EOpenModes.OpenForReadWrite);
                m_pulledFile.setPosTo(m_pulledFile.size());

                do
                {
                    resp = doRequest("GET", strUrl, null, oSession, headers, m_pulledFile.size());
                }while(!m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0);
            }finally{
                if (m_pulledFile != null)
                {
                    try { m_pulledFile.close(); }
                    catch (IOException e)
                    {
                        LOG.ERROR("file closing failed.", e);
                    }
                    m_pulledFile = null;
                }
            }

            copyHashtable(m_OutHeaders, headers);

            m_isPullFile       = false;
            m_nCurDownloadSize = 0;
            return(resp != null && !m_bCancel ? resp : makeResponse("", Convert.ToInt32(HttpStatusCode.InternalServerError)));
        }
示例#6
0
        public NetResponse pullFile(String strUrl, String strFileName, IRhoSession oSession, Hashtable <String, String> headers)
        {
/*		    IRAFile file = null;
 *                  NetResponse resp = null;
 *
 *                  m_nMaxPacketSize = RhoClassFactory.getNetworkAccess().getMaxPacketSize();
 *                  m_bFlushFileAfterWrite = RhoConf.getInstance().getBool("use_persistent_storage");
 *                  m_bCancel = false;
 *
 *                  try{
 *
 *                  if (!strFileName.startsWith("file:")) {
 *                  try{
 *                          strFileName = FilePath.join(RhoClassFactory.createFile().getDirPath(""), strFileName);
 *                  } catch (IOException x) {
 *                          LOG.ERROR("getDirPath failed.", x);
 *                      throw x;
 *                  }
 *                  }
 *
 *                          file = RhoClassFactory.createFSRAFile();
 *                          file.open(strFileName, "rw");
 *                          file.seek(file.size());
 *
 *                          do{
 *                                  resp = pullFile1( strUrl, file, file.size(), oSession, headers );
 *                          }while( !m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0 && m_nMaxPacketSize > 0 );
 *
 *                  }finally{
 *                          if ( file != null )
 *                          {
 *                                  file.close();
 *                                  file = null;
 *                          }
 *                  }
 *
 *                  copyHashtable(m_OutHeaders, headers);
 *
 *                  return resp != null && !m_bCancel ? resp : makeResponse("", IHttpConnection.HTTP_INTERNAL_ERROR );*/
            return(makeResponse("", 200));
        }
示例#7
0
        public NetResponse pullCookies(String strUrl, String strBody, IRhoSession oSession)
        {
            Hashtable <String, String> headers = new Hashtable <String, String>();

            m_bCancel = false;

            NetResponse resp = doRequest/*Try*/ ("POST", strUrl, strBody, oSession, headers);

            if (resp.isOK())
            {
                String strCookie = resp.getCookies();
                if (strCookie == null || strCookie.length() == 0)
                {
                    strCookie = "rho_empty";
                }

                resp.setCharData(strCookie);
                LOG.INFO("pullCookies: " + resp.getCharData());
            }

            return(resp);
        }
示例#8
0
        public NetResponse pushMultipartData(String strUrl, MultipartItem oItem, IRhoSession oSession, Hashtable<String,String> pHeaders)
        {
            Vector<MultipartItem> arItems = new Vector<MultipartItem>();
            arItems.addElement(oItem);

            return pushMultipartData(strUrl, arItems, oSession, pHeaders);
        }
示例#9
0
	    public NetResponse pushData(String strUrl, String strBody, IRhoSession oSession)
        {
		    m_bCancel = false;
		
		    if ( RHODESAPP().isRhodesAppUrl(strUrl) )
                return RHODESAPP().processCallback(strUrl, strBody);
		
		    return doRequest("POST", strUrl, strBody, oSession, null);
        }
示例#10
0
	    public NetResponse doRequest(String strMethod, String strUrl, String strBody, IRhoSession oSession, Hashtable<String, String> headers, long nRangePos = -1)
        {
            LOG.INFO("Url: " + strUrl + "; Body: " + strBody);
            m_respWaitEvent.WaitOne();
            m_respWaitEvent.Reset();

            m_oSession = oSession;
            m_strBody = strBody;
            m_strUrl = addUniqueParam(strUrl);
            m_headers = headers;
		
		    m_bCancel = false;

            closeConnection();
            m_webRequest = WebRequest.Create(m_strUrl) as HttpWebRequest;

            m_webRequest.CookieContainer = new CookieContainer();
            handleCookie(oSession);

            if ((strBody != null && strBody.length() > 0) || m_isPullFile || m_isMultiPart)
			{
                if (oSession != null)
                    m_webRequest.ContentType = oSession.getContentType();
                else if (m_isMultiPart)
                    m_webRequest.ContentType = "multipart/form-data; boundary=----------A6174410D6AD474183FDE48F5662FCC5";
                else if (m_isPullFile)
                {
                    if (nRangePos > 0)
                        m_webRequest.Headers["Range"] = "bytes=" + nRangePos.ToString() + "-";
                }
                else
                    m_webRequest.ContentType = "application/x-www-form-urlencoded";

				writeHeaders(headers);
                m_webRequest.Method = strMethod;

                if (!m_isPullFile)
                {
                    m_webRequest.BeginGetRequestStream(GetRequestStreamCallback, null);
                    m_reqWaitEvent.Reset();
                    m_reqWaitEvent.WaitOne();
                }
			}else
			{
				writeHeaders(headers);
                m_webRequest.Method = strMethod;
			}

            if(!m_isPullFile)
                m_webRequest.BeginGetResponse(GetResponseCallback, null);
            else
                m_webRequest.BeginGetResponse(GetPullFileCallback, null);

            m_respWaitEvent.Reset();
            m_respWaitEvent.WaitOne();

            m_isMultiPart = false;
            return makeResponse(m_strRespBody, m_code);
        }
示例#11
0
	    void handleCookie(IRhoSession oSession)
	    {
		    if ( oSession != null )
		    {
			    String strSession = oSession.getSession();
			    LOG.INFO("Cookie : " + (strSession != null ? strSession : "") );
                if (strSession != null && strSession.length() > 0 && !strSession.equals("rho_empty"))
                    m_webRequest.CookieContainer.SetCookies(new Uri(m_strUrl), strSession);
		    }
	    }
示例#12
0
 public NetResponse pullData(String strUrl, IRhoSession oSession)
 {
     return(doRequest("GET", strUrl, "", oSession, null));
 }
示例#13
0
        public NetResponse pushMultipartData(String strUrl, Vector<MultipartItem> arItems, IRhoSession oSession, Hashtable<String,String> headers)
        {
/*		    String strRespBody = null;
		    InputStream is = null;
		    OutputStream os = null;
		    int code  = -1;
		
		    m_bCancel = false;
    	
		    try{
			    closeConnection();
			    m_connection = RhoClassFactory.getNetworkAccess().connect(strUrl, false);
			
			    handleCookie(oSession);

			    m_connection.setRequestProperty("Connection", "keep-alive");
			    m_connection.setRequestProperty("content-type", szMultipartContType);
			    writeHeaders(headers);
			    m_connection.setRequestMethod(IHttpConnection.POST);
			
			    //PUSH specific
			    processMultipartItems( arItems );
			    os = m_connection.openOutputStream();
	            //write all items
	            for( int i = 0; i < (int)arItems.size(); i++ )
	            {
	                MultipartItem oItem = (MultipartItem)arItems.elementAt(i); 
    			    os.write(oItem.m_strDataPrefix.getBytes(), 0, oItem.m_strDataPrefix.length());

	                if ( oItem.m_strFilePath.length() > 0 )
	                {

		        	    SimpleFile file = null;
		    		    InputStream fis = null;
		        	
		    		    try{
		    			    file = RhoClassFactory.createFile();
		    			    file.open(oItem.m_strFilePath, true, true);
		        		
		    			    if ( !file.isOpened() ){
		    				    LOG.ERROR("File not found: " + oItem.m_strFilePath);
		    				    throw new RuntimeException("File not found:" + oItem.m_strFilePath);
		    			    }
		    			
		    			    fis = file.getInputStream();
		    			    byte[]  byteBuffer = new byte[1024*4]; 
		    			    int nRead = 0;
		        		    do{
		        			    nRead = fis.read(byteBuffer);	    			
		        			    if ( nRead > 0 )
		        				    os.write(byteBuffer, 0, nRead);
		        		    }while( nRead > 0 );
		    		    }finally{
						    if (fis != null)
							    try{ fis.close(); }catch(IOException e){}
		    			
		    			    if ( file != null )
		    				    try{ file.close(); }catch(IOException e){}
		    		    }
	    			
	                }else
	                {
	    			    os.write(oItem.m_strBody.getBytes(), 0, oItem.m_strBody.length());
	                }
	            }
			    os.write(szMultipartPostfix.getBytes(), 0, szMultipartPostfix.length());
			    //os.flush();
			    //PUSH specific
			
			    is = m_connection.openInputStream();
			    code = m_connection.getResponseCode();
		
			    LOG.INFO("getResponseCode : " + code);

			    readHeaders(headers);
			    copyHashtable(m_OutHeaders, headers);
			
			    if (code >= 400 ) 
			    {
				    LOG.ERROR("Error retrieving data: " + code);
				    if (code == IHttpConnection.HTTP_UNAUTHORIZED)
				    {
					    LOG.ERROR("Unauthorize error.Client will be logged out");
					    oSession.logout();
				    }
				
				    //if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
					    strRespBody = readFully(is, getResponseEncoding());
					    LOG.TRACE("Response body: " + strRespBody );
				
			    }else
			    {
				    long len = m_connection.getLength();
				    LOG.INFO("fetchRemoteData data size:" + len );
		
				    strRespBody = readFully(is, getResponseEncoding());
				
				    LOG.INFO("fetchRemoteData data readFully.");
			    }
			
		    }finally{
			    try{
				    if ( is != null )
					    is.close();
				    if (os != null)
					    os.close();
				
				    closeConnection();
				
			    }catch(IOException exc2){}
		    }
		
		    return makeResponse(strRespBody, code );  */
            return makeResponse("", 200 );
        }
示例#14
0
	    public NetResponse pullFile( String strUrl, String strFileName, IRhoSession oSession, Hashtable<String, String> headers )
	    {
		    NetResponse resp = null;
            m_isPullFile = true;

		    m_bCancel = false;
    	
		    try{

	            if (!strFileName.startsWith("file:")) { 
            	    try{
	            	    strFileName = CFilePath.join(CRhodesApp.getRhoRootPath(), strFileName);
            	    } catch (IOException e) { 
                 	    LOG.ERROR("getDirPath failed.", e);
                    }              	
	            }

                m_pulledFile = RhoClassFactory.createFile();
                m_pulledFile.open(strFileName, CRhoFile.EOpenModes.OpenForReadWrite);
                m_pulledFile.setPosTo(m_pulledFile.size());
			
			    do{
                    resp = doRequest("GET", strUrl, null, oSession, headers, m_pulledFile.size());
			    }while( !m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0);
			
		    }finally{
                if (m_pulledFile != null)
			    {
                    try { m_pulledFile.close(); }
                    catch (IOException e)
                    {
                        LOG.ERROR("file closing failed.", e);
                    }
                    m_pulledFile = null;
			    }
		    }
		
		    copyHashtable(m_OutHeaders, headers);

            m_isPullFile = false;
            m_nCurDownloadSize = 0;
            return resp != null && !m_bCancel ? resp : makeResponse("", Convert.ToInt32(HttpStatusCode.InternalServerError));
	    }
示例#15
0
	    public NetResponse pullCookies(String strUrl, String strBody, IRhoSession oSession)
	    {
		    Hashtable<String,String> headers = new Hashtable<String,String>();
		    m_bCancel = false;
    	
		    NetResponse resp = doRequest/*Try*/("POST", strUrl, strBody, oSession, headers);
		    if ( resp.isOK() )
		    {
			    String strCookie = resp.getCookies();
			    if ( strCookie == null || strCookie.length() == 0 )
				    strCookie = "rho_empty";
			
			    resp.setCharData(strCookie);
			    LOG.INFO("pullCookies: " + resp.getCharData() );
		    }
		
		    return resp;
	    }
示例#16
0
 public NetResponse pushMultipartData(String strUrl, Vector <MultipartItem> arItems, IRhoSession oSession, Hashtable <String, String> headers)
 {
     m_arItems     = arItems;
     m_isMultiPart = true;
     processMultipartItems(arItems);
     return(doRequest("POST", strUrl, null, oSession, headers));
 }
示例#17
0
        public NetResponse doRequest(String strMethod, String strUrl, String strBody, IRhoSession oSession, Hashtable <String, String> headers, long nRangePos = -1)
        {
            LOG.INFO("Url: " + strUrl + "; Body: " + strBody);
            m_respWaitEvent.WaitOne();
            m_respWaitEvent.Reset();

            m_oSession = oSession;
            m_strBody  = strBody;
            m_strUrl   = addUniqueParam(strUrl);
            m_headers  = headers;

            m_bCancel = false;

            closeConnection();
            m_webRequest = WebRequest.Create(m_strUrl) as HttpWebRequest;

            m_webRequest.CookieContainer = new CookieContainer();
            handleCookie(oSession);

            if ((strBody != null && strBody.length() > 0) || m_isPullFile || m_isMultiPart)
            {
                if (oSession != null && !m_isPullFile && !m_isMultiPart)
                {
                    m_webRequest.ContentType = oSession.getContentType();
                }
                else if (m_isMultiPart)
                {
                    m_webRequest.ContentType = "multipart/form-data; boundary=----------A6174410D6AD474183FDE48F5662FCC5";
                }
                else if (m_isPullFile)
                {
                    if (nRangePos > 0)
                    {
                        m_webRequest.Headers["Range"] = "bytes=" + nRangePos.ToString() + "-";
                    }
                }
                else
                {
                    m_webRequest.ContentType = "application/x-www-form-urlencoded";
                }

                writeHeaders(headers);
                m_webRequest.Method = strMethod;

                if (!m_isPullFile)
                {
                    m_webRequest.BeginGetRequestStream(GetRequestStreamCallback, null);
                    m_reqWaitEvent.Reset();
                    m_reqWaitEvent.WaitOne();
                }
            }
            else
            {
                writeHeaders(headers);
                m_webRequest.Method = strMethod;
            }

            if (!m_isPullFile)
            {
                m_webRequest.BeginGetResponse(GetResponseCallback, null);
            }
            else
            {
                m_webRequest.BeginGetResponse(GetPullFileCallback, null);
            }

            m_respWaitEvent.Reset();
            m_respWaitEvent.WaitOne();

            m_isMultiPart = false;
            return(makeResponse(m_strRespBody, m_code));
        }
示例#18
0
	    public NetResponse pullFile( String strUrl, String strFileName, IRhoSession oSession, Hashtable<String, String> headers )
	    {
/*		    IRAFile file = null;
		    NetResponse resp = null;
		
		    m_nMaxPacketSize = RhoClassFactory.getNetworkAccess().getMaxPacketSize();
		    m_bFlushFileAfterWrite = RhoConf.getInstance().getBool("use_persistent_storage");
		    m_bCancel = false;
    	
		    try{

	            if (!strFileName.startsWith("file:")) { 
            	    try{
	            	    strFileName = FilePath.join(RhoClassFactory.createFile().getDirPath(""), strFileName);
            	    } catch (IOException x) { 
                 	    LOG.ERROR("getDirPath failed.", x);
                        throw x;
                    }              	
	            }
			
			    file = RhoClassFactory.createFSRAFile();
			    file.open(strFileName, "rw");
			    file.seek(file.size());
			
			    do{
				    resp = pullFile1( strUrl, file, file.size(), oSession, headers );
			    }while( !m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0 && m_nMaxPacketSize > 0 );
			
		    }finally{
			    if ( file != null )
			    {
				    file.close();
				    file = null;
			    }
		    }
		
		    copyHashtable(m_OutHeaders, headers);
		
		    return resp != null && !m_bCancel ? resp : makeResponse("", IHttpConnection.HTTP_INTERNAL_ERROR );*/
            return makeResponse("",200);
	    }
示例#19
0
 public NetResponse pushMultipartData(String strUrl, Vector<MultipartItem> arItems, IRhoSession oSession, Hashtable<String,String> headers)
 {
     m_arItems = arItems;
     m_isMultiPart = true;
     processMultipartItems( arItems );
     return doRequest("POST", strUrl, null, oSession, headers);
 }
示例#20
0
        public NetResponse pushMultipartData(String strUrl, Vector <MultipartItem> arItems, IRhoSession oSession, Hashtable <String, String> headers)
        {
/*		    String strRespBody = null;
 *                  InputStream is = null;
 *                  OutputStream os = null;
 *                  int code  = -1;
 *
 *                  m_bCancel = false;
 *
 *                  try{
 *                          closeConnection();
 *                          m_connection = RhoClassFactory.getNetworkAccess().connect(strUrl, false);
 *
 *                          handleCookie(oSession);
 *
 *                          m_connection.setRequestProperty("Connection", "keep-alive");
 *                          m_connection.setRequestProperty("content-type", szMultipartContType);
 *                          writeHeaders(headers);
 *                          m_connection.setRequestMethod(IHttpConnection.POST);
 *
 *                          //PUSH specific
 *                          processMultipartItems( arItems );
 *                          os = m_connection.openOutputStream();
 *                  //write all items
 *                  for( int i = 0; i < (int)arItems.size(); i++ )
 *                  {
 *                      MultipartItem oItem = (MultipartItem)arItems.elementAt(i);
 *                          os.write(oItem.m_strDataPrefix.getBytes(), 0, oItem.m_strDataPrefix.length());
 *
 *                      if ( oItem.m_strFilePath.length() > 0 )
 *                      {
 *
 *                                  SimpleFile file = null;
 *                                  InputStream fis = null;
 *
 *                                  try{
 *                                          file = RhoClassFactory.createFile();
 *                                          file.open(oItem.m_strFilePath, true, true);
 *
 *                                          if ( !file.isOpened() ){
 *                                                  LOG.ERROR("File not found: " + oItem.m_strFilePath);
 *                                                  throw new RuntimeException("File not found:" + oItem.m_strFilePath);
 *                                          }
 *
 *                                          fis = file.getInputStream();
 *                                          byte[]  byteBuffer = new byte[1024*4];
 *                                          int nRead = 0;
 *                                          do{
 *                                                  nRead = fis.read(byteBuffer);
 *                                                  if ( nRead > 0 )
 *                                                          os.write(byteBuffer, 0, nRead);
 *                                          }while( nRead > 0 );
 *                                  }finally{
 *                                                  if (fis != null)
 *                                                          try{ fis.close(); }catch(IOException e){}
 *
 *                                          if ( file != null )
 *                                                  try{ file.close(); }catch(IOException e){}
 *                                  }
 *
 *                      }else
 *                      {
 *                                  os.write(oItem.m_strBody.getBytes(), 0, oItem.m_strBody.length());
 *                      }
 *                  }
 *                          os.write(szMultipartPostfix.getBytes(), 0, szMultipartPostfix.length());
 *                          //os.flush();
 *                          //PUSH specific
 *
 *                          is = m_connection.openInputStream();
 *                          code = m_connection.getResponseCode();
 *
 *                          LOG.INFO("getResponseCode : " + code);
 *
 *                          readHeaders(headers);
 *                          copyHashtable(m_OutHeaders, headers);
 *
 *                          if (code >= 400 )
 *                          {
 *                                  LOG.ERROR("Error retrieving data: " + code);
 *                                  if (code == IHttpConnection.HTTP_UNAUTHORIZED)
 *                                  {
 *                                          LOG.ERROR("Unauthorize error.Client will be logged out");
 *                                          oSession.logout();
 *                                  }
 *
 *                                  //if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
 *                                          strRespBody = readFully(is, getResponseEncoding());
 *                                          LOG.TRACE("Response body: " + strRespBody );
 *
 *                          }else
 *                          {
 *                                  long len = m_connection.getLength();
 *                                  LOG.INFO("fetchRemoteData data size:" + len );
 *
 *                                  strRespBody = readFully(is, getResponseEncoding());
 *
 *                                  LOG.INFO("fetchRemoteData data readFully.");
 *                          }
 *
 *                  }finally{
 *                          try{
 *                                  if ( is != null )
 *                                          is.close();
 *                                  if (os != null)
 *                                          os.close();
 *
 *                                  closeConnection();
 *
 *                          }catch(IOException exc2){}
 *                  }
 *
 *                  return makeResponse(strRespBody, code );  */
            return(makeResponse("", 200));
        }
示例#21
0
	    public NetResponse pullData(String strUrl, IRhoSession oSession )
        {
		    return doRequest("GET", strUrl, "", oSession, null);
        }
示例#22
0
	    public NetResponse doRequest(String strMethod, String strUrl, String strBody, IRhoSession oSession, Hashtable<String, String> headers )
        {
            m_respWaitEvent.WaitOne();
            m_respWaitEvent.Reset();


            m_oSession = oSession;
            m_strBody = strBody;
            m_strUrl = strUrl;
            m_headers = headers;
		
		    m_bCancel = false;

            m_webRequest = WebRequest.Create(strUrl) as HttpWebRequest;
            LOG.INFO("connection done");

            m_webRequest.CookieContainer = new CookieContainer();
            handleCookie(oSession);

			if ( strBody != null && strBody.length() > 0 )
			{
		        if ( oSession != null )
                    m_webRequest.ContentType = oSession.getContentType();
				else
                    m_webRequest.ContentType = "application/x-www-form-urlencoded";

				writeHeaders(headers);
				LOG.INFO("writeHeaders done");
                m_webRequest.Method = strMethod;
				
                m_webRequest.BeginGetRequestStream(GetRequestStreamCallback, null);
                m_reqWaitEvent.Reset();
                m_reqWaitEvent.WaitOne();
			}else
			{
				writeHeaders(headers);
                m_webRequest.Method = strMethod;
			}

            m_webRequest.BeginGetResponse(GetResponseCallback, null);
            m_respWaitEvent.Reset();
            m_respWaitEvent.WaitOne();

            return makeResponse(m_strRespBody, m_code);
        }