SF.net SVN: mod-aspdotnet: [200] mod_aspdotnet2/trunk/Apache.Web
Brought to you by:
wrowe
From: <wr...@us...> - 2007-08-15 07:18:37
|
Revision: 200 http://mod-aspdotnet.svn.sourceforge.net/mod-aspdotnet/?rev=200&view=rev Author: wrowe Date: 2007-08-15 00:18:36 -0700 (Wed, 15 Aug 2007) Log Message: ----------- Major Patch; Adopt VC 8.0 (Studio 2005) C++ syntax. Major changes include language class keywords, pinning pointers and explicit references (simplying "true" pointers). Modified Paths: -------------- mod_aspdotnet2/trunk/Apache.Web/Apache.Web.h mod_aspdotnet2/trunk/Apache.Web/Host.h mod_aspdotnet2/trunk/Apache.Web/HostFactory.h mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.cpp mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.h Modified: mod_aspdotnet2/trunk/Apache.Web/Apache.Web.h =================================================================== --- mod_aspdotnet2/trunk/Apache.Web/Apache.Web.h 2007-08-15 07:17:13 UTC (rev 199) +++ mod_aspdotnet2/trunk/Apache.Web/Apache.Web.h 2007-08-15 07:18:36 UTC (rev 200) @@ -1,4 +1,4 @@ -/* Copyright 2002-2006 Covalent Technologies +/* Copyright 2007 Covalent Technologies * * Covalent Technologies licenses this file to You under the Apache * Software Foundation's Apache License, Version 2.0 (the "License"); @@ -60,24 +60,22 @@ using namespace System::Runtime::Remoting::Lifetime; //using namespace System::Diagnostics; -#using "Apache.Web.Helpers.netmodule" - namespace Apache { namespace Web { // Forward declare a Host - public __gc class Host; + ref class Host; // Define using dispinterfaces for COM transition to ASP.Net - [InterfaceType(ComInterfaceType::InterfaceIsIDispatch)] - public __gc __interface IApacheWebHostFactory + public interface class IApacheWebHostFactory { public: - HRESULT Configure(String *path); + HRESULT Configure(String ^path); void Destroy(void); // Returns HostKey to pass on to HandleHostRequest() - int CreateHost(String *virtualPath, String *physicalPath, UINT_PTR ServerRecPtr); + int CreateHost(String ^virtualPath, String ^physicalPath, + UINT_PTR ServerRecPtr); // Returns HTTP Status from ApacheWebHost::HandleRequest int HandleHostRequest(int HostKey, UINT_PTR ReqRecordPtr); }; Modified: mod_aspdotnet2/trunk/Apache.Web/Host.h =================================================================== --- mod_aspdotnet2/trunk/Apache.Web/Host.h 2007-08-15 07:17:13 UTC (rev 199) +++ mod_aspdotnet2/trunk/Apache.Web/Host.h 2007-08-15 07:18:36 UTC (rev 200) @@ -1,4 +1,4 @@ -/* Copyright 2002-2006 Covalent Technologies +/* Copyright 2007 Covalent Technologies * * Covalent Technologies licenses this file to You under the Apache * Software Foundation's Apache License, Version 2.0 (the "License"); @@ -28,40 +28,41 @@ { namespace Web { - public __gc class HostFactory; + ref class HostFactory; - public __gc class Host : public MarshalByRefObject + public ref class Host : public MarshalByRefObject { private: // Create our utf8-encoding to handle utf8->unicode names - static Encoding *utf8_encoding = new UTF8Encoding(false); + static Encoding ^utf8_encoding = gcnew UTF8Encoding(false); // our default cultureNeutral object for proper strcmp's - static CultureInfo *nullCulture = CultureInfo::InvariantCulture; + static CultureInfo ^nullCulture = CultureInfo::InvariantCulture; // No trailing slash for this URI-path - String *virtualPath; + String ^virtualPath; // No trailing backslash for this filesystem path - String *physicalPath; + String ^physicalPath; - HostFactory *thisFactory; + HostFactory ^thisFactory; int thisHostKey; protected: - void ~Host(); + ~Host(); public: Host() { - thisFactory = NULL; + thisFactory = nullptr; thisHostKey = 0; } - virtual Object* InitializeLifetimeService() + virtual Object ^ InitializeLifetimeService() override { - ILease *lease - = __try_cast<ILease*>(MarshalByRefObject::InitializeLifetimeService()); - if (lease->CurrentState == System::Runtime::Remoting::Lifetime::LeaseState::Initial) { + ILease ^lease = dynamic_cast<ILease ^> + (MarshalByRefObject::InitializeLifetimeService()); + if (lease->CurrentState + == System::Runtime::Remoting::Lifetime::LeaseState::Initial) { lease->InitialLeaseTime = TimeSpan::FromDays(366); lease->SponsorshipTimeout = TimeSpan::FromMinutes(2); lease->RenewOnCallTime = TimeSpan::FromMinutes(1); @@ -70,8 +71,8 @@ } // Internal accessor for new Host construction - void Configure(String *VirtualPath, String *PhysicalPath, - HostFactory *Factory, int HostKey) + void Configure(String ^VirtualPath, String ^PhysicalPath, + HostFactory ^Factory, int HostKey) { // // The ApplicationHost::CreateApplicationHost() constructor @@ -85,83 +86,90 @@ virtualPath = VirtualPath->Replace(L'\\', L'/'); if (physicalPath->EndsWith(L"\\")) { physicalPath - = physicalPath->Substring(0, physicalPath->get_Length() - 1); + = physicalPath->Substring(0, physicalPath->Length - 1); } if (virtualPath->EndsWith(L"/")) { virtualPath - = virtualPath->Substring(0, virtualPath->get_Length() - 1); + = virtualPath->Substring(0, virtualPath->Length - 1); } } // Reports an error message in the error log - void LogRequestError(String *msg, int loglevel, apr_status_t rv, request_rec __nogc *rr) + void LogRequestError(String ^msg, int loglevel, apr_status_t rv, + request_rec *rr) { - unsigned char avalue __gc[] + array<unsigned char> ^avalue = utf8_encoding->GetBytes(msg); - unsigned char __pin *msg_text = &avalue[0]; - ap_log_rerror("Apache.Web", 0, loglevel | (rv ? 0 : APLOG_NOERRNO), rv, rr, - "mod_aspdotnet: %s", (char*) msg_text, NULL); + pin_ptr<unsigned char> msg_text = &avalue[0]; + ap_log_rerror("Apache.Web", 0, loglevel | (rv ? 0 : APLOG_NOERRNO), + rv, rr, "mod_aspdotnet: %s", (char*) msg_text, NULL); } - // Instantiates a new Apache.Web.WorkerRequest object from the given request_rec* + // Instantiates a new Apache.Web.WorkerRequest object from the given + // request_rec* int HandleRequest(UINT_PTR ReqRecordPtr) { try { - WorkerRequest *request = new WorkerRequest(ReqRecordPtr, this); + WorkerRequest ^request = gcnew WorkerRequest(ReqRecordPtr, + this); int status = request->Handler(); return status; } - catch (Exception *e) { + catch (Exception ^e) { LogRequestError(L"Failed to create ASP.NET Request, " L"Exception follows", APLOG_ERR, 0, - (request_rec __nogc *)ReqRecordPtr); + (request_rec *)ReqRecordPtr); LogRequestError(e->ToString(), APLOG_ERR, 0, - (request_rec __nogc *)ReqRecordPtr); + (request_rec *)ReqRecordPtr); return 500; } } // Returns the Virtual URI-path of this host, with no trailing slash - String *GetVirtualPath(void) { + String ^ GetVirtualPath(void) { return virtualPath; } - // Returns the Physical filesystem path of this host, with no trailing slash - String *GetPhysicalPath(void) { + // Returns the Physical filesystem path of this host, + // with no trailing slash + String ^ GetPhysicalPath(void) { return physicalPath; } - // Translate the given URI-path in this host's Virtual path to a filesystem path - String *MapPath(String *path, request_rec __nogc *rr) { + // Translate the given URI-path in this host's Virtual path to + // a filesystem path + String ^ MapPath(String ^path, request_rec *rr) { // - // ...relative to this host's Physical path. The function returns NULL - // if the given URI-path is outside of the Virtual path of this host. + // ...relative to this host's Physical path. The function + // returns NULL if the given URI-path is outside of the Virtual + // path of this host. // - String *buildpath; + String ^buildpath; - if (!path || (path->get_Length() <= 0)) { + if (!path || (path->Length <= 0)) { return physicalPath; } else { buildpath = path->Replace(L'/', L'\\'); } - String *testpath = path->Replace(L'\\', L'/'); + String ^testpath = path->Replace(L'\\', L'/'); - if (testpath->get_Chars(0) == L'/') { + if (testpath[0] == L'/') { if (String::Compare(testpath, 0, virtualPath, 0, - virtualPath->get_Length(), + virtualPath->Length, true, nullCulture)) { - String *res = String::Concat(L"MapPath: could not map ", path, - L" within ", virtualPath); + String ^res = String::Concat(L"MapPath: could not map ", + path, L" within ", + virtualPath); LogRequestError(res, APLOG_DEBUG, 0, rr); - return NULL; + return nullptr; } else { - if (testpath->get_Length() > virtualPath->get_Length()) { + if (testpath->Length > virtualPath->Length) { buildpath = String::Concat(physicalPath, buildpath->Substring( - virtualPath->get_Length())); + virtualPath->Length)); } else { buildpath = physicalPath; @@ -171,7 +179,7 @@ else { buildpath = String::Concat(physicalPath, L"\\", buildpath->Substring( - virtualPath->get_Length())); + virtualPath->Length)); } return buildpath; } Modified: mod_aspdotnet2/trunk/Apache.Web/HostFactory.h =================================================================== --- mod_aspdotnet2/trunk/Apache.Web/HostFactory.h 2007-08-15 07:17:13 UTC (rev 199) +++ mod_aspdotnet2/trunk/Apache.Web/HostFactory.h 2007-08-15 07:18:36 UTC (rev 200) @@ -1,4 +1,4 @@ -/* Copyright 2002-2006 Covalent Technologies +/* Copyright 2007 Covalent Technologies * * Covalent Technologies licenses this file to You under the Apache * Software Foundation's Apache License, Version 2.0 (the "License"); @@ -14,7 +14,8 @@ * limitations under the License. */ -// Apache::Web::HostFactory.h managed host engine for mod_aspdotnet initialization +// Apache::Web::HostFactory.h managed host engine for mod_aspdotnet +// initialization #pragma once @@ -28,26 +29,26 @@ namespace Web { // Forward declare a Host - public __gc class Host; + ref class Host; // The HostFactory engine to instantiate new Host objects - public __gc class HostFactory + public ref class HostFactory : public IApacheWebHostFactory, public MarshalByRefObject { private: // Create our utf8-encoding to handle utf8->unicode names - Encoding* utf8_encoding; - ArrayList* hostURI; - ArrayList* hostDir; - ArrayList* hostObj; - ArrayList* hostSvr; + Encoding ^utf8_encoding; + ArrayList ^hostURI; + ArrayList ^hostDir; + ArrayList ^hostObj; + ArrayList ^hostSvr; private: // Reports an error message in the error log - void LogServerError(String *msg, int loglevel, int rv, server_rec __nogc *s) + void LogServerError(String ^msg, int loglevel, int rv, server_rec *s) { - unsigned char avalue __gc[] = utf8_encoding->GetBytes(msg); - unsigned char __pin *msg_text = &avalue[0]; + array<unsigned char> ^avalue = utf8_encoding->GetBytes(msg); + pin_ptr<unsigned char> msg_text = &avalue[0]; ap_log_error("Apache.Web", 0, loglevel|(rv ? 0 : APLOG_NOERRNO), rv, s, "mod_aspdotnet: %s", (char*) msg_text, NULL); } @@ -55,18 +56,19 @@ public: HostFactory() { - utf8_encoding = new UTF8Encoding(false); - hostURI = new ArrayList(); - hostDir = new ArrayList(); - hostObj = new ArrayList(); - hostSvr = new ArrayList(); + utf8_encoding = gcnew UTF8Encoding(false); + hostURI = gcnew ArrayList(); + hostDir = gcnew ArrayList(); + hostObj = gcnew ArrayList(); + hostSvr = gcnew ArrayList(); } - virtual Object* InitializeLifetimeService() + virtual Object ^ InitializeLifetimeService() override { - ILease *lease - = __try_cast<ILease*>(MarshalByRefObject::InitializeLifetimeService()); - if (lease->CurrentState == System::Runtime::Remoting::Lifetime::LeaseState::Initial) { + ILease ^lease = dynamic_cast<ILease^> + (MarshalByRefObject::InitializeLifetimeService()); + if (lease->CurrentState + == System::Runtime::Remoting::Lifetime::LeaseState::Initial) { lease->InitialLeaseTime = TimeSpan::FromDays(366); lease->SponsorshipTimeout = TimeSpan::FromMinutes(2); lease->RenewOnCallTime = TimeSpan::FromMinutes(1); @@ -74,8 +76,9 @@ return lease; } - // Returns E_FAIL if HostFactory cannot be configured; path is a noop argument - HRESULT Configure(String *path) + // Returns E_FAIL if HostFactory cannot be configured; + // path is a noop argument + virtual HRESULT Configure(String ^path) { #ifdef _DEBUG if (!WorkerRequest::CodeValidate()) @@ -85,101 +88,101 @@ return S_OK; } - void Destroy(void) + virtual void Destroy(void) { if (utf8_encoding) { - utf8_encoding = NULL; - int hosts = hostObj->get_Count(); + utf8_encoding = nullptr; + int hosts = hostObj->Count; for (int i = 0; i < hosts; ++i) { // Don't fault if the hostObj is already destroyed try { - hostObj->set_Item(i, NULL); + hostObj[i] = nullptr; } - catch (Exception * /*e*/) { + catch (Exception ^ /*e*/) { } } - hostURI = NULL; - hostDir = NULL; - hostObj = NULL; - hostSvr = NULL; + hostURI = nullptr; + hostDir = nullptr; + hostObj = nullptr; + hostSvr = nullptr; } } // Instantiate a new Host object; trailing slashes are acceptable bool ConnectHost(int HostKey) { - Type* hostType = __typeof(Host); - Object* newHost; + Type ^hostType = Host::typeid; + Object ^newHost; try { newHost = ApplicationHost::CreateApplicationHost(hostType, - __try_cast<String*>(hostURI->get_Item(HostKey)), - __try_cast<String*>(hostDir->get_Item(HostKey))); - hostObj->set_Item(HostKey, newHost); + dynamic_cast<String^>(hostURI[HostKey]), + dynamic_cast<String^>(hostDir[HostKey])); + hostObj[HostKey] = newHost; if (newHost) { - Host *host = __try_cast<Host*>(newHost); + Host ^host = dynamic_cast<Host^>(newHost); host->Configure( - __try_cast<String*>(hostURI->get_Item(HostKey)), - __try_cast<String*>(hostDir->get_Item(HostKey)), + dynamic_cast<String^>(hostURI[HostKey]), + dynamic_cast<String^>(hostDir[HostKey]), this, HostKey); return true; } else { - server_rec __nogc *s = (server_rec __nogc *) - (*__try_cast<__box int*>(hostSvr->get_Item(HostKey))); + server_rec *s = + (server_rec *)(static_cast<UINT_PTR>(hostSvr[HostKey])); LogServerError(L"mod_aspdotnet: CreateApplicationHost " L"returned NULL, perhaps the AspNetMount " L"paths were invalid", APLOG_ERR, 0, s); } } - catch (Exception *e) { - server_rec __nogc *s = (server_rec __nogc *) - (*__try_cast<__box int*>(hostSvr->get_Item(HostKey))); + catch (Exception ^e) { + server_rec *s = (server_rec *) + (server_rec *)(static_cast<UINT_PTR>(hostSvr[HostKey])); LogServerError(L"mod_aspdotnet: CreateApplicationHost failed, " L"Exception follows", APLOG_ERR, 0, s); LogServerError(e->ToString(), APLOG_ERR, 0, s); - hostObj->set_Item(HostKey, NULL); + hostObj[HostKey] = nullptr; } return false; } - void HostFinalized(int HostKey, Host *thisHost) + void HostFinalized(int HostKey, Host ^thisHost) { // Destroy only the correct host Threading::Monitor::Enter(this); - if (thisHost->Equals(hostObj->get_Item(HostKey))) + if (thisHost->Equals(hostObj[HostKey])) { try { - hostObj->set_Item(HostKey, NULL); + hostObj[HostKey] = nullptr; } - catch (Exception * /*e*/) { + catch (Exception ^ /*e*/) { } } Threading::Monitor::Exit(this); } // Instantiate a new Host object; trailing slashes are acceptable - int CreateHost(String* virtualPath, String* physicalPath, UINT_PTR ServerRecPtr) + virtual int CreateHost(String ^virtualPath, String ^physicalPath, + UINT_PTR ServerRecPtr) { int newHostKey; physicalPath = physicalPath->Replace(L'/', L'\\'); - newHostKey = hostObj->get_Count(); - // TODO: WHY are we boxing an int? - hostSvr->Add(__box(ServerRecPtr)); + newHostKey = hostObj->Count; + hostSvr->Add(ServerRecPtr); hostURI->Add(virtualPath); hostDir->Add(physicalPath); - hostObj->Add(NULL); + hostObj->Add(nullptr); if (!ConnectHost(newHostKey)) { - server_rec __nogc *s = (server_rec __nogc *)ServerRecPtr; - String *msg = String::Concat(L"Mount failure creating host ", - __try_cast<String*>(hostURI->get_Item(newHostKey)), + server_rec *s = (server_rec *)ServerRecPtr; + String ^msg = String::Concat(L"Mount failure creating host ", + dynamic_cast<String^>(hostURI[newHostKey]), L" mapped to ", - __try_cast<String*>(hostDir->get_Item(newHostKey))); + dynamic_cast<String^>(hostDir[newHostKey])); LogServerError(msg, APLOG_ERR, 0, s); newHostKey = -1; } @@ -187,30 +190,30 @@ return newHostKey; } - int HandleHostRequest(int HostKey, UINT_PTR ReqRecordPtr) { - request_rec __nogc *rr = (request_rec __nogc *)ReqRecordPtr; - String* msg; + virtual int HandleHostRequest(int HostKey, UINT_PTR ReqRecordPtr) { + request_rec *rr = (request_rec *)ReqRecordPtr; + String ^msg; - Object* obj = hostObj->get_Item(HostKey); - if (obj != NULL) { + Object ^obj = hostObj[HostKey]; + if (obj != nullptr) { try { - Host* host = __try_cast<Host*>(obj); + Host ^host = dynamic_cast<Host^>(obj); int status = host->HandleRequest(ReqRecordPtr); return status; } // Presume all Remoting/AppDomainUnloadedExceptions // require us to recreate the Host. Fall through... - catch (System::Runtime::Remoting::RemotingException *e) { + catch (System::Runtime::Remoting::RemotingException ^e) { msg = String::Concat(L"RemotingException; ", e->ToString()); LogServerError(msg, APLOG_DEBUG, 0, rr->server); } - catch (System::AppDomainUnloadedException *e) { + catch (System::AppDomainUnloadedException ^e) { msg = String::Concat(L"AppDomainUnloadedException; ", e->ToString()); LogServerError(msg, APLOG_DEBUG, 0, rr->server); } - catch (Exception *e) { + catch (Exception ^e) { msg = String::Concat(L"HandleRequest: Failed with " L"unexpected Exception; ", e->ToString()); @@ -220,62 +223,64 @@ } msg = String::Concat(L"Restarting host of ", - __try_cast<String*>(hostURI->get_Item(HostKey)), + dynamic_cast<String^>(hostURI[HostKey]), L" mapped to ", - __try_cast<String*>(hostDir->get_Item(HostKey))); + dynamic_cast<String^>(hostDir[HostKey])); LogServerError(msg, APLOG_INFO, 0, rr->server); int welocked = 0; try { Threading::Monitor::Enter(this); welocked = 1; - Object* tryobj = hostObj->get_Item(HostKey); + Object ^tryobj = hostObj[HostKey]; if (tryobj == obj) { // Release all stale obj references and catch any // sort of dispatch exceptions (and ignore them). try { - hostObj->set_Item(HostKey, NULL); + hostObj[HostKey] = nullptr; } - catch (Exception * /*e*/) { + catch (Exception ^ /*e*/) { } try { obj = tryobj; } - catch (Exception * /*e*/) { + catch (Exception ^ /*e*/) { } } - if (obj == NULL) { + if (obj == nullptr) { if (!ConnectHost(HostKey)) { Threading::Monitor::Exit(this); - msg = String::Concat(L"Mount failed to connect restarting host ", - __try_cast<String*>(hostURI->get_Item(HostKey)), + msg = String::Concat(L"Mount failed to connect ", + L"to the restarting host ", + dynamic_cast<String^>(hostURI[HostKey]), L" mapped to ", - __try_cast<String*>(hostDir->get_Item(HostKey))); + dynamic_cast<String^>(hostDir[HostKey])); LogServerError(msg, APLOG_ERR, 0, rr->server); return 500; } - obj = hostObj->get_Item(HostKey); + obj = hostObj[HostKey]; if (!obj) { Threading::Monitor::Exit(this); - msg = String::Concat(L"Mount failed to query restarting host ", - __try_cast<String*>(hostURI->get_Item(HostKey)), + msg = String::Concat(L"Mount failed to query ", + L"the restarting host ", + dynamic_cast<String^>(hostURI[HostKey]), L" mapped to ", - __try_cast<String*>(hostDir->get_Item(HostKey))); + dynamic_cast<String^>(hostDir[HostKey])); LogServerError(msg, APLOG_ERR, 0, rr->server); return 500; } } Threading::Monitor::Exit(this); } - catch (Exception *e) { + catch (Exception ^e) { if (welocked) { Threading::Monitor::Exit(this); } msg = String::Concat(L"Mount failure restarting host ", - __try_cast<String*>(hostURI->get_Item(HostKey)), + dynamic_cast<String^>(hostURI[HostKey]), L" mapped to ", - __try_cast<String*>(hostDir->get_Item(HostKey))); + dynamic_cast<String^>(hostDir[HostKey])); LogServerError(msg, APLOG_ERR, 0, rr->server); msg = String::Concat(L"Mount failure exception restarting " L"host; ", e->ToString()); @@ -284,11 +289,11 @@ } try { - Host* host = __try_cast<Host*>(obj); + Host ^host = dynamic_cast<Host^>(obj); int status = host->HandleRequest(ReqRecordPtr); return status; } - catch (Exception *e) { + catch (Exception ^e) { msg = String::Concat(L"RequestHandler; failure following " L"host restart; ", e->ToString()); LogServerError(msg, APLOG_ERR, 0, rr->server); @@ -297,7 +302,7 @@ } protected: - void ~HostFactory() + ~HostFactory() { Destroy(); } Modified: mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.cpp =================================================================== --- mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.cpp 2007-08-15 07:17:13 UTC (rev 199) +++ mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.cpp 2007-08-15 07:18:36 UTC (rev 200) @@ -29,59 +29,59 @@ try { thisFactory->HostFinalized(thisHostKey, this); } - catch (Exception * /*e*/) { + catch (Exception ^ /*e*/) { } } -Apache::Web::WorkerRequest::WorkerRequest(UINT_PTR Req, Host *ThisHost) - : SimpleWorkerRequest(String::Empty, String::Empty, 0) +Apache::Web::WorkerRequest::WorkerRequest(UINT_PTR Req, Host ^ThisHost) + : SimpleWorkerRequest(String::Empty, String::Empty, nullptr) { // Initialize empty placeholders - request_headers_value = new String* [RequestHeaderMaximum]; - unk_req_header_name = new ArrayList(); - unk_req_header_index = new ArrayList(); - unk_req_header_value = new ArrayList(); - env_name = new ArrayList(); - env_value = new ArrayList(); - serverName = NULL; - remoteName = NULL; + request_headers_value = gcnew array<String^>(RequestHeaderMaximum); + unk_req_header_name = gcnew ArrayList(); + unk_req_header_index = gcnew ArrayList(); + unk_req_header_value = gcnew ArrayList(); + env_name = gcnew ArrayList(); + env_value = gcnew ArrayList(); + serverName = nullptr; + remoteName = nullptr; seen_eos = 0; body_sent = 0; bytes_read = 0; // Initialize state pointers to our encoding, request and host - rr = (request_rec __nogc *)Req; + rr = (request_rec *)Req; host = ThisHost; // Deal with the usual request variables - uri = rr->uri; - unparsed_uri = rr->unparsed_uri; + uri = gcnew String(rr->uri); + unparsed_uri = gcnew String(rr->unparsed_uri); - queryargs = rr->args; + queryargs = gcnew String(rr->args); if (!rr->args || !*rr->args) { - query_raw = new unsigned char __gc[0]; + query_raw = gcnew array<unsigned char>(0); } else { apr_size_t len = strlen(rr->args); - query_raw = new unsigned char __gc[len]; - unsigned char __pin *foo = &query_raw[0]; + query_raw = gcnew array<unsigned char>(len); + pin_ptr<unsigned char> foo = &query_raw[0]; memcpy(foo, rr->args, len); } // rr->filename is utf-8 encoded for Apache 2.0/WinNT - filename = new String(rr->filename ? rr->filename : "", 0, - rr->filename ? strlen(rr->filename) : 0, - utf8_encoding); + filename = gcnew String(rr->filename ? rr->filename : "", 0, + rr->filename ? strlen(rr->filename) : 0, + utf8_encoding); filename = filename->Replace(L'/', L'\\'); // Now deal with the client's request headers - const apr_array_header_t __nogc* arr = apr_table_elts(rr->headers_in); - const char __nogc* elt = arr->elts; + const apr_array_header_t *arr = apr_table_elts(rr->headers_in); + const char *elt = arr->elts; for (int i = 0; i < arr->nelts; ++i, elt += arr->elt_size) { - apr_table_entry_t __nogc* pair = (apr_table_entry_t *)(void*)(elt); - String* key(pair->key); - String* val(pair->val); - String* key_index(key->ToLower(nullCulture)); + apr_table_entry_t *pair = (apr_table_entry_t *)(void*)(elt); + String ^key = gcnew String(pair->key); + String ^val = gcnew String(pair->val); + String ^key_index = gcnew String(key->ToLower(nullCulture)); int ent = Array::IndexOf(request_headers_index_s, key_index); if (ent >= 0) { request_headers_value[ent] = val; @@ -93,22 +93,22 @@ } } - int elts = unk_req_header_value->get_Count(); - unk_req_hdr_arr = new _gcA_gcA_gcString(elts); + int elts = unk_req_header_value->Count; + unk_req_hdr_arr = gcnew array<array<String^>^>(elts); for (int i = 0; i < elts; ++i) { - String __gc* ent __gc[] = new String __gc* __gc[2]; - ent[0] = static_cast<String *>(unk_req_header_name->get_Item(i)); - ent[1] = static_cast<String *>(unk_req_header_value->get_Item(i)); - unk_req_hdr_arr->Set(i, ent); + array<String^> ^ent = gcnew array<String^>(2); + ent[0] = static_cast<String ^>(unk_req_header_name[i]); + ent[1] = static_cast<String ^>(unk_req_header_value[i]); + unk_req_hdr_arr[i] = ent; } arr = apr_table_elts(rr->subprocess_env); elt = arr->elts; for (int i = 0; i < arr->nelts; ++i, elt += arr->elt_size) { - apr_table_entry_t __nogc* pair = (apr_table_entry_t *)(void*)(elt); - String* var(pair->key); - String* val(pair->val); + apr_table_entry_t *pair = (apr_table_entry_t *)(void*)(elt); + String ^var = gcnew String(pair->key); + String ^val = gcnew String(pair->val); env_name->Add(var); env_value->Add(val); } @@ -119,53 +119,55 @@ // after Apache::Web::WorkerRequest // -void Apache::Web::WorkerRequest::LogRequestError(String *msg, int loglevel, int rv) { +void Apache::Web::WorkerRequest::LogRequestError(String ^msg, int loglevel, + int rv) { host->LogRequestError(msg, loglevel, rv, rr); } -String* Apache::Web::WorkerRequest::MapPath(String* path) +String ^ Apache::Web::WorkerRequest::MapPath(String ^path) { - String *mapped = host->MapPath(path, rr); + String ^mapped = host->MapPath(path, rr); #ifdef _DEBUG - String *res = String::Concat(L"MapPath: ", path, + String ^res = String::Concat(L"MapPath: ", path, L" mapped to ", mapped); LogRequestError(res, APLOG_DEBUG, 0); #endif return mapped; } -String* Apache::Web::WorkerRequest::GetAppPath(void) +String ^ Apache::Web::WorkerRequest::GetAppPath(void) { #ifdef _DEBUG - String *res = String::Concat(L"GetAppPath: returns ", host->GetVirtualPath()); + String ^res = String::Concat(L"GetAppPath: returns ", + host->GetVirtualPath()); LogRequestError(res, APLOG_DEBUG, 0); #endif return host->GetVirtualPath(); } -String* Apache::Web::WorkerRequest::GetAppPathTranslated(void) +String ^ Apache::Web::WorkerRequest::GetAppPathTranslated(void) { - String *bslashed = host->GetPhysicalPath(); - bslashed = bslashed->Insert(bslashed->get_Length(), L"\\"); + String ^bslashed = host->GetPhysicalPath(); + bslashed = bslashed->Insert(bslashed->Length, L"\\"); #ifdef _DEBUG - String *res = String::Concat(L"GetAppPathTranslated: returns ", bslashed); + String ^res = String::Concat(L"GetAppPathTranslated: returns ", bslashed); LogRequestError(res, APLOG_DEBUG, 0); #endif return bslashed; } -String* Apache::Web::WorkerRequest::GetFilePath(void) +String ^ Apache::Web::WorkerRequest::GetFilePath(void) { // Break URI matching filename, ignoring path_info - String* strip = host->GetPhysicalPath(); - String* path = filename; + String ^strip = host->GetPhysicalPath(); + String ^path = filename; if (path->StartsWith(strip)) { - path = path->Substring(strip->get_Length()); + path = path->Substring(strip->Length); path = path->Insert(0, host->GetVirtualPath()); path = path->Replace(L'\\', L'/'); } #ifdef _DEBUG - String *res = String::Concat(L"GetFilePath: returns ", path); + String ^res = String::Concat(L"GetFilePath: returns ", path); LogRequestError(res, APLOG_DEBUG, 0); #endif return path; @@ -173,11 +175,11 @@ #pragma unmanaged -static apr_status_t InternalFlushResponse(request_rec __nogc *rr) +static apr_status_t InternalFlushResponse(request_rec *rr) { - conn_rec __nogc *c = rr->connection; - apr_bucket_brigade __nogc *bb; - apr_bucket __nogc *b; + conn_rec *c = rr->connection; + apr_bucket_brigade *bb; + apr_bucket *b; bb = apr_brigade_create(rr->pool, c->bucket_alloc); b = apr_bucket_eos_create(c->bucket_alloc); @@ -197,7 +199,7 @@ // Report completion if (eosnCallback) { eosnCallback->Invoke(this, eosnExtra); - eosnCallback = NULL; + eosnCallback = nullptr; } #ifdef _DEBUG LogRequestError(L"FlushResponse: final", APLOG_DEBUG, 0); @@ -212,13 +214,13 @@ #pragma unmanaged -static apr_status_t InternalResponseFromMemory(request_rec __nogc *rr, - const char __nogc *buf_data, +static apr_status_t InternalResponseFromMemory(request_rec *rr, + const char *buf_data, int length) { - conn_rec __nogc *c = rr->connection; - apr_bucket_brigade __nogc *bb; - apr_bucket __nogc *b; + conn_rec *c = rr->connection; + apr_bucket_brigade *bb; + apr_bucket *b; bb = apr_brigade_create(rr->pool, c->bucket_alloc); b = apr_bucket_transient_create(buf_data, length, c->bucket_alloc); @@ -234,15 +236,16 @@ { if (!length) { #ifdef _DEBUG - LogRequestError("SendResponseFromMemory: passed zero byte buffer!", APLOG_DEBUG, 0); + LogRequestError("SendResponseFromMemory: passed zero byte buffer!", + APLOG_DEBUG, 0); #endif return; } - const char __nogc *buf_data - = static_cast<const char __nogc *>(data.ToPointer()); + const char *buf_data + = static_cast<const char *>(data.ToPointer()); #ifdef _DEBUG - String *res = String::Concat(L"SendResponseFromMemory: passed ", + String ^res = String::Concat(L"SendResponseFromMemory: passed ", (new Int32(length))->ToString(), L" byte buffer"); LogRequestError(res, APLOG_DEBUG, 0); @@ -259,13 +262,13 @@ } #pragma unmanaged -static apr_status_t InternalResponseFromFile(request_rec __nogc *rr, HANDLE hv, +static apr_status_t InternalResponseFromFile(request_rec *rr, HANDLE hv, __int64 offset, __int64 length) { - conn_rec __nogc *c = rr->connection; - apr_bucket_brigade __nogc *bb; - apr_bucket __nogc *b; - apr_file_t __nogc *fd; + conn_rec *c = rr->connection; + apr_bucket_brigade *bb; + apr_bucket *b; + apr_file_t *fd; apr_off_t fsize; apr_status_t rv; @@ -319,13 +322,14 @@ { if (!length) { #ifdef _DEBUG - LogRequestError("SendResponseFromFile: passed zero byte length!", APLOG_DEBUG, 0); + LogRequestError("SendResponseFromFile: passed zero byte length!", + APLOG_DEBUG, 0); #endif return; } #ifdef _DEBUG - String *res = String::Concat(L"SendResponseFromFile: passed ", + String ^res = String::Concat(L"SendResponseFromFile: passed ", (new Int64(length))->ToString(), L" byte request starting at offset ", (new Int64(offset))->ToString()); @@ -347,9 +351,9 @@ #pragma unmanaged -static apr_status_t InternalReadEntityBody(request_rec __nogc* rr, char __nogc* curptr, - apr_size_t size, int __nogc* bytes_read, - int __nogc* overflow, int __nogc* seen_eos) +static apr_status_t InternalReadEntityBody(request_rec *rr, char *curptr, + apr_size_t size, int *bytes_read, + int *overflow, int *seen_eos) { apr_bucket_brigade *bb; apr_status_t rv; @@ -357,15 +361,15 @@ *bytes_read = 0; // Reader-Writer helpers - apr_bucket __nogc *dummy_flush_bucket; - apr_bucket __nogc *dummy_eos_bucket; + apr_bucket *dummy_flush_bucket; + apr_bucket *dummy_eos_bucket; dummy_flush_bucket = apr_bucket_flush_create(rr->connection->bucket_alloc); dummy_eos_bucket = apr_bucket_eos_create(rr->connection->bucket_alloc); bb = apr_brigade_create(rr->pool, rr->connection->bucket_alloc); do { apr_bucket *bucket; - apr_size_t size_one = (HUGE_STRING_LEN <= size ? HUGE_STRING_LEN : size); + apr_size_t size_one = (HUGE_STRING_LEN <= size? HUGE_STRING_LEN: size); if ((rv = ap_get_brigade(rr->input_filters, bb, AP_MODE_READBYTES, @@ -414,22 +418,24 @@ #pragma managed -int Apache::Web::WorkerRequest::ReadEntityBody(unsigned char buffer __gc[], - int size) +int Apache::Web::WorkerRequest::ReadEntityBody(array<unsigned char> ^buffer, + int size) { - if (buffer->get_Length() < 1) { + if (buffer->Length < 1) { #ifdef _DEBUG - LogRequestError(L"ReadEntityBody: noread (passed 0 byte buffer)", APLOG_DEBUG, 0); + LogRequestError(L"ReadEntityBody: noread (passed 0 byte buffer)", + APLOG_DEBUG, 0); #endif return 0; } - int __pin *eos = &seen_eos; + pin_ptr<int> eos = &seen_eos; int read; int overflow; - unsigned char __pin *lockbuff = &buffer[0]; - void *startptr = static_cast<void __nogc*>(lockbuff); - apr_status_t rv = InternalReadEntityBody(rr, static_cast<char __nogc*>(startptr), - (apr_size_t)size, &read, &overflow, eos); + pin_ptr<unsigned char> lockbuff = &buffer[0]; + void *startptr = static_cast<void *>(lockbuff); + apr_status_t rv = InternalReadEntityBody(rr, static_cast<char *>(startptr), + (apr_size_t)size, &read, &overflow, + eos); bytes_read += read; if (rv != APR_SUCCESS) { LogRequestError(L"ReadEntityBody: brigade read failure " @@ -440,7 +446,7 @@ L"reading the request body", APLOG_ERR, rv); } #ifdef _DEBUG - String *res = String::Concat(L"ReadEntityBody: read ", + String ^res = String::Concat(L"ReadEntityBody: read ", (new Int32(read))->ToString(), L" bytes"); LogRequestError(res, APLOG_DEBUG, 0); @@ -451,8 +457,8 @@ int Apache::Web::WorkerRequest::Handler(void) { - wait_complete = new System::Threading::ManualResetEvent(false); - apr_bucket_brigade __nogc* bb; + wait_complete = gcnew System::Threading::ManualResetEvent(false); + apr_bucket_brigade *bb; apr_status_t rv; apr_size_t size = 0; @@ -460,18 +466,18 @@ // // Yes, this code is remarkably similar to InternalReadEntityBody, // however, for speed that code is entirely managed and incapable - // of allocating a char __gc[] that we need below. In the code - // below, we allocate exactly the correct __gc[] required to + // of allocating a char ref [] that we need below. In the code + // below, we allocate exactly the correct ref [] required to // store the initial bytes, up to the MS semi-standard 49152. // - apr_bucket __nogc *dummy_flush_bucket; - apr_bucket __nogc *dummy_eos_bucket; + apr_bucket *dummy_flush_bucket; + apr_bucket *dummy_eos_bucket; dummy_flush_bucket = apr_bucket_flush_create(rr->connection->bucket_alloc); dummy_eos_bucket = apr_bucket_eos_create(rr->connection->bucket_alloc); bb = apr_brigade_create(rr->pool, rr->connection->bucket_alloc); - apr_bucket __nogc* bucket; + apr_bucket *bucket; if ((rv = ap_get_brigade(rr->input_filters, bb, AP_MODE_READBYTES, @@ -480,13 +486,13 @@ apr_off_t sz; rv = apr_brigade_length(bb, 1, &sz); size = (apr_size_t)sz; - preread_body = new unsigned char __gc[size]; - unsigned char __pin *lockbuff; - char __nogc *curptr = NULL; + preread_body = gcnew array<unsigned char>(size); + pin_ptr<unsigned char> lockbuff; + char *curptr = NULL; if (size > 0) { lockbuff = &preread_body[0]; - void *startptr = static_cast<void __nogc*>(lockbuff); - curptr = static_cast<char __nogc*>(startptr); + void *startptr = static_cast<void *>(lockbuff); + curptr = static_cast<char *>(startptr); } while (!APR_BRIGADE_EMPTY(bb)) { bucket = APR_BRIGADE_FIRST(bb); @@ -523,7 +529,7 @@ } apr_brigade_cleanup(bb); #ifdef _DEBUG - String *res = String::Concat(L"Handler: preread ", + String ^res = String::Concat(L"Handler: preread ", (new Int64(bytes_read))->ToString(), L" request body bytes"); LogRequestError(res, APLOG_DEBUG, 0); @@ -538,12 +544,12 @@ try { HttpRuntime::ProcessRequest(this); } - catch (Exception *e) { + catch (Exception ^e) { if (!body_sent) { rr->status = 500; rr->status_line = ap_get_status_line(rr->status); } - String *msg = String::Concat(L"ProcessRequest: fatal exception " + String ^msg = String::Concat(L"ProcessRequest: fatal exception " L"processing request ", uri, L" exception follows;"); LogRequestError(msg, APLOG_ERR, 0); Modified: mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.h =================================================================== --- mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.h 2007-08-15 07:17:13 UTC (rev 199) +++ mod_aspdotnet2/trunk/Apache.Web/WorkerRequest.h 2007-08-15 07:18:36 UTC (rev 200) @@ -1,4 +1,4 @@ -/* Copyright 2002-2006 Covalent Technologies +/* Copyright 2007 Covalent Technologies * * Covalent Technologies licenses this file to You under the Apache * Software Foundation's Apache License, Version 2.0 (the "License"); @@ -25,123 +25,129 @@ #include "http_header_arrays.h" -using namespace Apache::Web::Helpers; using namespace System::Collections; using namespace System::Globalization; +using namespace cli; namespace Apache { namespace Web { // Forward declare a Host - public __gc class Host; + ref class Host; - public __gc class WorkerRequest : public SimpleWorkerRequest + public ref class WorkerRequest : public SimpleWorkerRequest { private: - static const char __nogc *response_headers_name_c __nogc[] = { + static array<const char *> ^response_headers_name_c = { response_headers_m("") }; - // static const char __nogc *request_headers_name_c __nogc[] = { + //* Unused variant, but trivial to enable later + // static array<const char *> ^request_headers_name_c = { // request_headers_m("") // }; - static String* response_headers_name_s[] = { + static array<String^> ^response_headers_name_s = { response_headers_m(L) }; - static String* request_headers_name_s[] = { + static array<String^> ^request_headers_name_s = { request_headers_m(L) }; - static String* response_headers_index_s[] = { + static array<String^> ^response_headers_index_s = { response_headers_index_m(L) }; - static String* request_headers_index_s[] = { + static array<String^> ^request_headers_index_s = { request_headers_index_m(L) }; // Create our utf8-encoding to handle utf8->unicode names - static Encoding *utf8_encoding = new UTF8Encoding(false); + static Encoding ^utf8_encoding = gcnew UTF8Encoding(false); // Create our invariant culture for handling ASCII case - static CultureInfo *nullCulture = CultureInfo::InvariantCulture; + static CultureInfo ^nullCulture = CultureInfo::InvariantCulture; - String* uri; - String* unparsed_uri; - String* queryargs; - String* filename; - String* remoteName; - String* serverName; + String ^uri; + String ^unparsed_uri; + String ^queryargs; + String ^filename; + String ^remoteName; + String ^serverName; - unsigned char query_raw __gc[]; + array<unsigned char> ^query_raw; - String* request_headers_value[]; - ArrayList* unk_req_header_name; - ArrayList* unk_req_header_index; - ArrayList* unk_req_header_value; - ArrayList* env_name; - ArrayList* env_value; + array<String^> ^request_headers_value; + ArrayList ^unk_req_header_name; + ArrayList ^unk_req_header_index; + ArrayList ^unk_req_header_value; + ArrayList ^env_name; + ArrayList ^env_value; - _gcA_gcA_gcString *unk_req_hdr_arr; + array<array<String^>^> ^unk_req_hdr_arr; - request_rec __nogc *rr; + request_rec *rr; - Host* host; - System::Threading::ManualResetEvent* wait_complete; - EndOfSendNotification *eosnCallback; - Object* eosnExtra; + Host ^host; + System::Threading::ManualResetEvent ^wait_complete; + EndOfSendNotification ^eosnCallback; + Object ^eosnExtra; - unsigned char preread_body __gc[]; + array<unsigned char> ^preread_body; int seen_eos; int body_sent; __int64 bytes_read; // Reports an error message in the error log - void LogRequestError(String *msg, int loglevel, apr_status_t rv); + void LogRequestError(String ^msg, int loglevel, apr_status_t rv); public: static bool CodeValidate() { - if (response_headers_name_s->get_Length() != ResponseHeaderMaximum) + if (response_headers_name_s->Length != ResponseHeaderMaximum) return false; - if (response_headers_index_s->get_Length() != ResponseHeaderMaximum) + if (response_headers_index_s->Length != ResponseHeaderMaximum) return false; for (int i = 0; i < ResponseHeaderMaximum; ++i) { - String *s = HttpWorkerRequest::GetKnownResponseHeaderName(i); + String ^s = HttpWorkerRequest::GetKnownResponseHeaderName(i); if (response_headers_name_s[i]->CompareTo(s) != 0) return false; - if (response_headers_index_s[i]->CompareTo(s->ToLower(nullCulture)) != 0) + if (response_headers_index_s[i]->CompareTo( + s->ToLower(nullCulture)) + != 0) return false; } - if (request_headers_name_s->get_Length() != RequestHeaderMaximum) + if (request_headers_name_s->Length != RequestHeaderMaximum) return false; - if (request_headers_index_s->get_Length() != RequestHeaderMaximum) + if (request_headers_index_s->Length != RequestHeaderMaximum) return false; for (int i = 0; i < RequestHeaderMaximum; ++i) { - String *s = HttpWorkerRequest::GetKnownRequestHeaderName(i); + String ^s = HttpWorkerRequest::GetKnownRequestHeaderName(i); if (request_headers_name_s[i]->CompareTo(s) != 0) return false; - if (request_headers_index_s[i]->CompareTo(s->ToLower(nullCulture)) != 0) + if (request_headers_index_s[i]->CompareTo( + s->ToLower(nullCulture)) + != 0) return false; } return true; - } + }; // Cannot be declared inline, we don't have Host defined - virtual String* GetAppPath(void); - virtual String* GetAppPathTranslated(void); + virtual String ^ GetAppPath(void) override ; + virtual String ^ GetAppPathTranslated(void) override; - WorkerRequest(UINT_PTR ReqRecordPtr, Host *ThisHost); + WorkerRequest(UINT_PTR ReqRecordPtr, Host ^ThisHost); int Handler(void); [ComVisible(false)] virtual void SetEndOfSendNotification( - HttpWorkerRequest::EndOfSendNotification *callback, - Object* extraData) + HttpWorkerRequest::EndOfSendNotification ^callback, + Object ^extraData) override { #ifdef _DEBUG - LogRequestError(L"SetEndOfSendNotification: initialized", APLOG_DEBUG, 0); + LogRequestError(L"SetEndOfSendNotification: initialized", + APLOG_DEBUG, 0); #endif } - virtual void EndOfRequest(void) + virtual void EndOfRequest(void) override { // If ProcessRequest() in Handler completed before the request // request processing completes, it blocks on wait_complete, @@ -149,10 +155,11 @@ // or would block on upon return from ProcessRequest(). if (eosnCallback) { #ifdef _DEBUG - LogRequestError(L"EndOfRequest: invoked EndOfSendNotification", APLOG_DEBUG, 0); + LogRequestError(L"EndOfRequest: invoked EndOfSendNotification", + APLOG_DEBUG, 0); #endif eosnCallback->Invoke(this, eosnExtra); - eosnCallback = NULL; + eosnCallback = nullptr; } #ifdef _DEBUG else @@ -161,222 +168,228 @@ wait_complete->Set(); } - virtual String* GetUriPath(void) + virtual String ^ GetUriPath(void) override { #ifdef _DEBUG - String *res = String::Concat(L"GetUriPath: returns ", uri); + String ^res = String::Concat(L"GetUriPath: returns ", uri); LogRequestError(res, APLOG_DEBUG, 0); #endif return uri; } - virtual String* GetQueryString(void) + virtual String ^ GetQueryString(void) override { #ifdef _DEBUG - String *res = String::Concat(L"GetQueryString: returns ", queryargs); + String ^res = String::Concat(L"GetQueryString: returns ", + queryargs); LogRequestError(res, APLOG_DEBUG, 0); #endif return queryargs; } - virtual unsigned char GetQueryStringRawBytes(void) __gc[] + virtual array<unsigned char> ^ GetQueryStringRawBytes(void) override { #ifdef _DEBUG - String *res = String::Concat(L"GetQueryStringRawBytes: returns ", - (new Int32(query_raw->get_Length()))->ToString(), + String ^res = String::Concat(L"GetQueryStringRawBytes: returns ", + (new Int32(query_raw->Length))->ToString(), L" raw characters"); LogRequestError(res, APLOG_DEBUG, 0); #endif return query_raw; } - virtual String* GetRawUrl(void) + virtual String ^ GetRawUrl(void) override { #ifdef _DEBUG - String *res = String::Concat(L"GetRawUrl: returns ", unparsed_uri); + String ^res = String::Concat(L"GetRawUrl: returns ", unparsed_uri); LogRequestError(res, APLOG_DEBUG, 0); #endif return unparsed_uri; } - virtual String* GetHttpVerbName(void) + virtual String ^ GetHttpVerbName(void) override { - String* verb = new String(rr->method); + String ^verb = gcnew String(rr->method); #ifdef _DEBUG - String *res = String::Concat(L"GetHttpVerbName: returns ", verb); + String ^res = String::Concat(L"GetHttpVerbName: returns ", verb); LogRequestError(res, APLOG_DEBUG, 0); #endif return verb; } - virtual String* GetHttpVersion(void) + virtual String ^ GetHttpVersion(void) override { - String* version = new String(rr->protocol); + String ^version = gcnew String(rr->protocol); #ifdef _DEBUG - String *res = String::Concat(L"GetHttpVersion: returns ", version); + String ^res = String::Concat(L"GetHttpVersion: returns ", version); LogRequestError(res, APLOG_DEBUG, 0); #endif return version; } - virtual String* GetProtocol(void) + virtual String ^ GetProtocol(void) override { #if MODULE_MAGIC_NUMBER_MAJOR >= 20050101 // Fixes in httpd-2.1-dev - const char __nogc *method = ap_http_scheme(rr); + const char *method = ap_http_scheme(rr); #else - const char __nogc *method = ap_http_method(rr); + const char *method = ap_http_method(rr); #endif - String *scheme(method); + String ^scheme = gcnew String(method); // For some silly reason, the ASP.NET team thought that schemes // are upper case entities; scheme = scheme->ToUpper(nullCulture); #ifdef _DEBUG - String *schemeMsg = String::Concat(L"GetProtocol: returns ", scheme); - LogRequestError(schemeMsg, APLOG_DEBUG, 0); + String ^res = String::Concat(L"GetProtocol: returns ", scheme); + LogRequestError(res, APLOG_DEBUG, 0); #endif return scheme; } - virtual String* GetRemoteAddress(void) + virtual String ^ GetRemoteAddress(void) override { - String* addr = new String(rr->connection->remote_ip); + String ^addr = gcnew String(rr->connection->remote_ip); #ifdef _DEBUG - String *res = String::Concat(L"GetRemoteAddress: returns ", addr); + String ^res = String::Concat(L"GetRemoteAddress: returns ", addr); LogRequestError(res, APLOG_DEBUG, 0); #endif return addr; } - virtual int GetRemotePort(void) + virtual int GetRemotePort(void) override { #ifdef _DEBUG - String *res = String::Concat(L"GetRemotePort: returns ", + String ^res = String::Concat(L"GetRemotePort: returns ", (new Int32(rr->connection->remote_addr->port))->ToString()); LogRequestError(res, APLOG_DEBUG, 0); #endif return rr->connection->remote_addr->port; } - virtual String* GetRemoteName(void) + virtual String ^ GetRemoteName(void) override { if (!remoteName) { - const char __nogc *name = ap_get_remote_host(rr->connection, - rr->per_dir_config, - REMOTE_HOST, NULL); + const char *name = ap_get_remote_host(rr->connection, + rr->per_dir_config, + REMOTE_HOST, NULL); if (!name) remoteName = String::Empty; else - remoteName = new String(name); + remoteName = gcnew String(name); } #ifdef _DEBUG - String *res = String::Concat(L"GetRemoteName: returns ", remoteName); + String ^res = String::Concat(L"GetRemoteName: returns ", + remoteName); LogRequestError(res, APLOG_DEBUG, 0); #endif return remoteName; } - virtual String* GetServerName(void) + virtual String ^ GetServerName(void) override { if (!serverName) { - const char __no... [truncated message content] |