Skip to content

Instantly share code, notes, and snippets.

@gregoryyoung
Created July 3, 2013 10:13
Show Gist options
  • Save gregoryyoung/5916838 to your computer and use it in GitHub Desktop.
Save gregoryyoung/5916838 to your computer and use it in GitHub Desktop.
from httplistener.cs
else {
throw new ArgumentException(SR.GetString(SR.net_listener_scheme), "uriPrefix");
}
bool inSquareBrakets = false;
int j = i;
while (j<uriprefix.length &&="" uriprefix[j]!="/" (uriprefix[j]!=":" ||="" insquarebrakets))="" {="" if="" (uriprefix[j]="='[')" (insquarebrakets)="" j="i;" break;="" }="" insquarebrakets="true;" (insquarebrakets="" uriprefix[j]="=']')" j++;="" (i="=j)" throw="" new="" argumentexception(sr.getstring(sr.net_listener_host),="" "uriprefix");="" (uriprefix[uriprefix.length-1]!="/" )="" argumentexception(sr.getstring(sr.net_listener_slash),="" registeredprefix="uriPrefix[j]==':'" ?="" string.copy(uriprefix)="" :="" uriprefix.substring(0,="" j)="" +="" ":80"="" ":443")="" uriprefix.substring(j);="" fixed="" (char*="" pchar="registeredPrefix)" i="0;" while="" (pchar[i]!=":" pchar[i]="(char)CaseInsensitiveAscii.AsciiToLower[(byte)pChar[i]];" i++;="" globallog.print("httplistener#"="" validationhelper.hashstring(this)="" "::addprefix()="" mapped="" uriprefix:"="" uriprefix="" "="" to="" registeredprefix:"="" registeredprefix);="" (m_state="=State.Started)" calling="" unsafenclnativemethods.httpapi.httpaddurl[tourlgroup]");="" uint="" statuscode="InternalAddPrefix(registeredPrefix);" (statuscode!="UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)" (statuscode="=" unsafenclnativemethods.errorcodes.error_already_exists)="" httplistenerexception((int)statuscode,="" sr.getstring(sr.net_listener_already,="" registeredprefix));="" else="" httplistenerexception((int)statuscode);="" m_uriprefixes[uriprefix]="registeredPrefix;" m_defaultservicenames.add(uriprefix);="" catch="" (exception="" exception)="" if(logging.on)logging.exception(logging.httplistener,="" this,="" "addprefix",="" exception);="" throw;="" finally="" if(logging.on)logging.exit(logging.httplistener,="" "prefix:"="" public="" httplistenerprefixcollection="" prefixes="" get="" if(logging.on)logging.enter(logging.httplistener,="" "prefixes_get",="" "");="" checkdisposed();="" (m_prefixes="=null)" m_prefixes="new" httplistenerprefixcollection(this);="" return="" m_prefixes;="" internal="" bool="" removeprefix(string="" uriprefix)="" "removeprefix",="" "uriprefix:"="" uriprefix);="" try="" "::removeprefix()="" (uriprefix="=null)" argumentnullexception("uriprefix");="" if(!m_uriprefixes.contains(uriprefix)){="" false;="" internalremoveprefix((string)m_uriprefixes[uriprefix]);="" m_uriprefixes.remove(uriprefix);="" m_defaultservicenames.remove(uriprefix);="" true;="" void="" removeall(bool="" clear)="" "removeall",="" go="" through="" the="" uri="" list="" and="" unregister="" for="" each="" one="" of="" them="" (m_uriprefixes.count="">0) {
if (m_State==State.Started) {
foreach (string registeredPrefix in m_UriPrefixes.Values) {
// ignore possible failures
InternalRemovePrefix(registeredPrefix);
}
}
if (clear) {
m_UriPrefixes.Clear();
m_DefaultServiceNames.Clear();
}
}
@gregoryyoung
Copy link
Author

from HTTPListener in the .net framework. Scroll right on line 6 ;-)

@ChrisMcKee
Copy link

Thats pretty ;)

@robashton
Copy link

Looks some of my early university work on parsers

@gregoryyoung
Copy link
Author

@robashton
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment