This method wraps around xmlrpc_decode_request, since it is borken in many ways. This wraps
around all the ugliness needed to make it not dump core and not print expat warnings.
173867
private function parseRequest( $request_xml ) {
		$xml = @simplexml_load_string($request_xml);
		if (!$xml && !$xml->getNamespaces()) { 
			// FIXME: check for protocol json-rpc
			//simplexml in combination with namespaces (soap) lets $xml evaluate to false
			return  xmlrpc_encode_request( 
				null, 
				ripcord::fault( -3, 'Invalid Method Call - Ripcord Server accepts only XML-RPC, SimpleRPC or SOAP 1.1 calls'), 
				$this->outputOptions
			);
		} else {
			// prevent segmentation fault on incorrect xmlrpc request (without methodName)
			$methodCall = $xml->xpath('//methodCall'); 
			if ($methodCall) { //xml-rpc
				$methodName = $xml->xpath('//methodName');
				if (!$methodName) {
					return xmlrpc_encode_request(
						null,
						ripcord::fault( -3, 'Invalid Method Call - No methodName given'),
						$this->outputOptions
					);
				}
			}
		}
		$method = null;
		ob_start(); // xmlrpc_decode echo expat errors if the xml is not valid, can't stop it.
		$params = xmlrpc_decode_request($request_xml, $method);
		ob_end_clean(); // clean up any xml errors
		return array( 'methodName' => $method, 'params' => $params );
	}
1255261
def _handle_response(response, **kwargs) -> XMLResponse:
        
        if not response.encoding:
            response.encoding = DEFAULT_ENCODING

        return response
411513
def _init_decoder(self):
        
        # Note: content-encoding value should be case-insensitive, per RFC 7230
        # Section 3.2
        content_encoding = self.headers.get('content-encoding', '').lower()
        if self._decoder is None and content_encoding in self.CONTENT_DECODERS:
            self._decoder = _get_decoder(content_encoding)
290103
function(request){
      // Don't geocode if the requested address is empty
      if (!request.address) {
        return;
      }
      if (this.options.bounds && !request.bounds){
        if (this.options.bounds === true){
          request.bounds = this.map && this.map.getBounds();
        } else {
          request.bounds = this.options.bounds;
        }
      }

      if (this.options.country){
        request.region = this.options.country;
      }

      this.geocoder.geocode(request, $.proxy(this.handleGeocode, this));
    }
102250
function Request(reqBytes){
  var parsed;
  var err

  try {
    parsed = types.Request.decode(reqBytes);
  } catch (e) {
    err = e;
  }


  //Check for request errors here
  if(err){
    this.BadRequest = true;
    this.errCode = types.CodeType.EncodingError;
    this.errMsg = "The request failed to be decoded"
  } else if(!types.methodLookup[parsed.type]){
    //Request type not recognized
    //Make a request object for the error
    this.BadRequest = true;
    this.errCode = types.CodeType.UnknownRequest;
    this.errMsg = "The request type was not understood"
  } else {

    this.BadRequest = false; 
    this.type = parsed.type;
    this.method = types.methodLookup[this.type];
    this.data = parsed.data.buffer.slice(parsed.data.offset);
    this.dataLength = parsed.data.limit - parsed.data.offset;
    this.dataLittle = parsed.data.littleEndian;
    this.key = parsed.key;
    this.value = parsed.value;
  }
}
79232
def decoder(self, response: bytes):
        
        response = response[:-(len(self.SEPARATOR))]
        if self.compreser is not None:
            response = self.compreser.decompress(response)
        if self.debug is True:
            response = json.loads(response.decode('utf-8'))
        else:
            response = msgpack.unpackb(response, encoding='utf-8')
        version = response.get("MPRPC")
        if version and version == self.VERSION:
            return response
        else:
            raise ProtocolException("Wrong Protocol")
1206690
def cleanup_request(request):
        
        for method_type in ('GET', 'PUT', 'POST', 'DELETE'):
            block = getattr(request, method_type, { })

            if True in [ k.startswith("oauth_") for k in block.keys() ]:
                sanitized = block.copy()

                for k in sanitized.keys():
                    if k.startswith("oauth_"):
                        sanitized.pop(k)

                setattr(request, method_type, sanitized)

        return request
839829
def raw(self, url, extra_headers=None, params=None):
        ''
        r = self.request(url, extra_headers=extra_headers, params=params)
        # uncomment to dump raw xml
#         with open('/tmp/%s.xml' % time.time(), 'wb') as f:
#             f.write(r.content)

        if not r.ok:
            o = lxml.objectify.fromstring(r.content)
            JFSError.raiseError(o, url)
        return r.content
1154343
def wrap_xml(self, xml, encoding ='ISO-8859-1', standalone='no'):
        
        header = '''<?xml version="1.0" encoding="%s" standalone="%s"?>''' %(encoding, standalone)
        return  header+xml
948004
def put_rsrc(rsrc, xml)
      validate_connected

      # convert CRs & to &#13;
      xml.gsub!(/\r/, '&#13;')

      # send the data
      @last_http_response = @cnx[rsrc].put(xml, content_type: 'text/xml')
    rescue RestClient::ExceptionWithResponse => e
      handle_http_error e
    end
1113651
private IoBuffer encodeProxyRequestPacket(final SocksProxyRequest request)
            throws UnsupportedEncodingException {
        int len = 6;
        InetSocketAddress adr = request.getEndpointAddress();
        byte addressType = 0;
        byte[] host = null;
        
        if (adr != null && !adr.isUnresolved()) {
            if (adr.getAddress() instanceof Inet6Address) {
                len += 16;
                addressType = SocksProxyConstants.IPV6_ADDRESS_TYPE;
            } else if (adr.getAddress() instanceof Inet4Address) {
                len += 4;
                addressType = SocksProxyConstants.IPV4_ADDRESS_TYPE;
            }
        } else {
            host = request.getHost() != null ? 
                    request.getHost().getBytes("ASCII") : null;

            if (host != null) {
                len += 1 + host.length;
                addressType = SocksProxyConstants.DOMAIN_NAME_ADDRESS_TYPE;
            } else {
                throw new IllegalArgumentException("SocksProxyRequest object " +
                        "has no suitable endpoint information");
            }
        }
        
        IoBuffer buf = IoBuffer.allocate(len);

        buf.put(request.getProtocolVersion());
        buf.put(request.getCommandCode());
        buf.put((byte) 0x00); // Reserved
        buf.put(addressType);

        if (host == null) {
            buf.put(request.getIpAddress());
        } else {
            buf.put((byte) host.length);
            buf.put(host);            
        }

        buf.put(request.getPort());

        return buf;
    }
468821
public function handleRPCMethod(PhpXmlRpc\Request $request) {
        $username=$request->getParam(1)->scalarval();
        $password=$request->getParam(2)->scalarval();
        
        if($this->authenticate($username, $password)) {
            $encoder=new PhpXmlRpc\Encoder();
            $method=str_replace(array('blogger.', 'metaWeblog.', 'kapost.'), '', $request->methodname);
            
            if(!in_array($request->methodname, $this->exposed_methods) || !method_exists($this, $method)) {
                return $this->httpError(403, _t('KapostService.METHOD_NOT_ALLOWED', '_Action "{method}" is not allowed on class Kapost Service.', array('method'=>$request->methodname)));
            }
            
            
            //Pack params into call to method if they are not the authentication parameters
            $params=array();
            for($i=0;$i<$request->getNumParams();$i++) {
                if($i!=1 && $i!=2) {
                    $params[]=$encoder->decode($request->getParam($i));
                }
            }
            
            
            //Convert the custom fields to an associtive array
            if(array_key_exists(1, $params) && is_array($params[1]) && array_key_exists('custom_fields', $params[1])) {
                $params[1]['custom_fields']=$this->struct_to_assoc($params[1]['custom_fields']);
            }
            
            
            //If transactions are supported start one for newPost and editPost
            if(($method=='newPost' || $method=='editPost') && DB::getConn()->supportsTransactions()) {
                DB::getConn()->transactionStart();
            }
            
            
            //Call the method
            try {
                $response=call_user_func_array(array($this, $method), $params);
                if($response instanceof PhpXmlRpc\Response) {
                    //If transactions are supported check the response and rollback in the case of a fault
                    if(($method=='newPost' || $method=='editPost' || $method=='newMediaObject') && DB::getConn()->supportsTransactions()) {
                        if($response->faultCode()!=0) {
                            DB::getConn()->transactionRollback();
                        }else {
                            DB::getConn()->transactionEnd();
                        }
                    }
                    
                    return $response; //Response is already encoded so return
                }
            }catch(ValidationException $e) {
                if(DB::getConn()->supportsTransactions()) {
                    DB::getConn()->transactionRollback();
                }
                
                return new PhpXmlRpc\Response(0, 400, $e->getMessage());
            }
            
            //Encode the response
            $response=$encoder->encode($response);
            if(is_object($response) && $response instanceof PhpXmlRpc\Value) {
                $response=new PhpXmlRpc\Response($response);
                
                if(($method=='newPost' || $method=='editPost' || $method=='newMediaObject') && DB::getConn()->supportsTransactions()) {
                    if($response->faultCode()!=0) {
                        DB::getConn()->transactionRollback();
                    }else {
                        DB::getConn()->transactionEnd();
                    }
                }
                
                return $response;
            }
            
            return $this->httpError(500, _t('KapostService.INVALID_RESPONSE', '_Invalid response returned from {method}, response was: {response}', array(
                                                                                                                                                        'method'=>$method,
                                                                                                                                                        'response'=>print_r($response, true)
                                                                                                                                                    )));
        }
        
        
        return $this->httpError(401, _t('KapostService.AUTH_FAIL', '_Authentication Failed, please check the App Center credentials for the SilverStripe end point.'));
    }
893423
def decodeXML( text )
      encodingStrings( true ) { |key,value| text.gsub!( value, key ) if text }
      text.gsub!( /&#([0-9]{2,3});/ ) { |c| $1.chr } if text
      text
   end
1125930
public function decode()
    {
        try {

            $this->body = new \SimpleXMLElement($this->body, LIBXML_NOWARNING);
        } catch (\Exception $e) {

            throw new \OtherCode\Rest\Exceptions\RestException($e->getMessage(), $e->getCode());
        }
    }
1276295
protected function parse_request() {
        // Retrieve and clean the POST/GET parameters from the parameters specific to the server.
        parent::set_web_service_call_settings();

        if ($this->authmethod == WEBSERVICE_AUTHMETHOD_USERNAME) {
            $this->username = isset($_GET['wsusername']) ? $_GET['wsusername'] : null;
            $this->password = isset($_GET['wspassword']) ? $_GET['wspassword'] : null;
        } else {
            $this->token = isset($_GET['wstoken']) ? $_GET['wstoken'] : null;
        }

        // Get the XML-RPC request data.
        $rawpostdata = $this->fetch_input_content();
        $methodname = null;

        // Decode the request to get the decoded parameters and the name of the method to be called.
        $decodedparams = xmlrpc_decode_request($rawpostdata, $methodname, 'UTF-8');
        $methodinfo = external_api::external_function_info($methodname);
        $methodparams = array_keys($methodinfo->parameters_desc->keys);
        $methodvariables = [];

        // Add the decoded parameters to the methodvariables array.
        if (is_array($decodedparams)) {
            foreach ($decodedparams as $index => $param) {
                // See MDL-53962 - XML-RPC requests will usually be sent as an array (as in, one with indicies).
                // We need to use a bit of "magic" to add the correct index back. Zend used to do this for us.
                $methodvariables[$methodparams[$index]] = $param;
            }
        }

        $this->functionname = $methodname;
        $this->parameters = $methodvariables;
    }
194738
function WrappedRequest(msg, hdrs, req) {
  this._msg = msg;
  this.headers = hdrs || {};
  this.request = req || {};
}
1009250
public static RequestContext handle(final HttpServletRequest request, final HttpServletResponse response) {
        try {
            request.setCharacterEncoding("UTF-8");
            response.setCharacterEncoding("UTF-8");
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, "Sets request context character encoding failed", e);
        }

        final RequestContext ret = new RequestContext();
        ret.setRequest(request);
        ret.setResponse(response);
        Latkes.REQUEST_CONTEXT.set(ret);

        for (final Handler handler : HANDLERS) {
            ret.addHandler(handler);
        }

        ret.handle();
        result(ret);
        Latkes.REQUEST_CONTEXT.set(null);

        return ret;
    }