Sends an XML request to the EPP server, and receives an XML response.
 <tt><login></tt> and <tt><logout></tt> requests are also wrapped
 around the request, so we can close the socket immediately after
 the request is made.
176453
def request(xml)
      open_connection
      
      @logged_in = true if login
      
      begin
        @response = send_request(xml)
      ensure
        @logged_in = false if @logged_in && logout
                
        close_connection
      end
      
      return @response
    end
205208
def send_proxy_connect_request(req)
      return unless req.uri.https? && req.using_proxy?

      @pending_request = true

      req.connect_using_proxy @socket

      @pending_request  = false
      @pending_response = true

      read_headers!
      @proxy_response_headers = @parser.headers

      if @parser.status_code != 200
        @failed_proxy_connect = true
        return
      end

      @parser.reset
      @pending_response = false
    end
310981
function() {
            var i, responseType;
            // Stop sending state
            sending = false;
            clearTimeout(timeout);
            // Launch next stacked request
            if(request_stack.length) {
                request_stack.shift().send();
            }
            // Verify if the request has not been previously aborted
            if(aborted) {
                return;
            }
            // Decrease the number of requests
            --requests;
            // Handle response
            try{
                // Process response
                if(nativeResponseParsing) {
                    if('response' in xhr && xhr.response === null) {
                        throw 'The request response is empty';
                    }
                    response = xhr.response;
                }
                else {
                    // Guess response type
                    responseType = options.responseType;
                    if(responseType == 'auto') {
                        if(xdr) {
                            responseType = defaultXdrResponseType;
                        }
                        else {
                            var ct = xhr.getResponseHeader('Content-Type') || '';
                            if(ct.indexOf(mimeTypes.json)>-1) {
                                responseType = 'json';
                            }
                            else if(ct.indexOf(mimeTypes.xml) > -1) {
                                responseType = 'xml';
                            }
                            else {
                                responseType = 'text';
                            }
                        }
                    }
                    // Handle response type
                    switch(responseType) {
                        case 'json':
                            if(xhr.responseText.length) {
                                try {
                                    if('JSON' in global) {
                                        response = JSON.parse(xhr.responseText);
                                    }
                                    else {
                                        response = new Function('return (' + xhr.responseText + ')')();
                                    }
                                }
                                catch(e) {
                                    throw "Error while parsing JSON body : "+e;
                                }
                            }
                            break;
                        case 'xml':
                            // Based on jQuery's parseXML() function
                            try {
                                // Standard
                                if(global.DOMParser) {
                                    response = (new DOMParser()).parseFromString(xhr.responseText,'text/xml');
                                }
                                // IE<9
                                else {
                                    response = new ActiveXObject('Microsoft.XMLDOM');
                                    response.async = 'false';
                                    response.loadXML(xhr.responseText);
                                }
                            }
                            catch(e) {
                                response = undefined;
                            }
                            if(!response || !response.documentElement || response.getElementsByTagName('parsererror').length) {
                                throw 'Invalid XML';
                            }
                            break;
                        default:
                            response = xhr.responseText;
                    }
                }
                // Late status code verification to allow passing data when, per example, a 409 is returned
                // --- https://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
                if('status' in xhr && !/^2|1223/.test(xhr.status)) {
                    throw xhr.status + ' (' + xhr.statusText + ')';
                }
                // Fulfilled
                promise(true, [xhr, response]);
            }
            catch(e) {
                // Rejected
                promise(false, [e, xhr, response]);
            }
        }
1175261
private void sendRequest(byte[] reqBytes, URLConnection connection) {
        HttpURLConnection httpconnection = (HttpURLConnection) connection;
        OutputStream out = null;
        try {
            if (connectTimeout > 0) {
                httpconnection.setConnectTimeout(connectTimeout);
            }
            if (readTimeout > 0) {
                httpconnection.setReadTimeout(readTimeout);
            }
            httpconnection.setRequestMethod("POST");
            httpconnection.setUseCaches(false);
            httpconnection.setDoInput(true);
            httpconnection.setDoOutput(true);
            httpconnection.setRequestProperty("Content-Type", serializeHandler.getProtocol()
                    .getName() + ";charset=" + NaviRpcClientConstant.ENDODING);
            httpconnection.setRequestProperty("Content-Length", StringUtil.EMPTY + reqBytes.length);
            httpconnection.connect();
            out = httpconnection.getOutputStream();
            out.write(reqBytes);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Send " + reqBytes.length + " bytes done");
            }
        } catch (Exception e) {
            throw new RpcException("Rpc send request failed - " + e.getMessage() + " on "
                    + connection.getURL(), e);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    LOG.error("Close send request connection error");
                }
            }
        }
    }
899729
private function sendRequest($xml)
    {
        $url = $this->url;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, ["Content-Type:application/xml"]);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

        $resp = curl_exec($curl);
        if (false === $resp) {
            throw new Exception(curl_error($curl) . ' ' . curl_errno($curl), curl_errno($curl));
        }

        curl_close($curl);

        return $resp;
    }
1125895
protected void handleEcpRequest(final HttpServletResponse response, final HttpServletRequest request,
                                    final MessageContext soapContext, final Credential credential,
                                    final String binding) {
        LOGGER.debug("Handling ECP request for SOAP context [{}]", soapContext);

        val envelope = soapContext.getSubcontext(SOAP11Context.class).getEnvelope();
        SamlUtils.logSamlObject(getSamlProfileHandlerConfigurationContext().getOpenSamlConfigBean(), envelope);

        val authnRequest = (AuthnRequest) soapContext.getMessage();
        val authenticationContext = Pair.of(authnRequest, soapContext);
        try {
            LOGGER.trace("Verifying ECP authentication request [{}]", authnRequest);
            val serviceRequest = verifySamlAuthenticationRequest(authenticationContext, request);

            LOGGER.trace("Attempting to authenticate ECP request for credential id [{}]", credential.getId());
            val authentication = authenticateEcpRequest(credential, authenticationContext);
            LOGGER.debug("Authenticated [{}] successfully with authenticated principal [{}]",
                credential.getId(), authentication.getPrincipal());

            LOGGER.trace("Building ECP SAML response for [{}]", credential.getId());
            val issuer = SamlIdPUtils.getIssuerFromSamlObject(authnRequest);
            val service = getSamlProfileHandlerConfigurationContext().getWebApplicationServiceFactory().createService(issuer);
            val casAssertion = buildCasAssertion(authentication, service, serviceRequest.getKey(), new LinkedHashMap<>());

            LOGGER.trace("CAS assertion to use for building ECP SAML response is [{}]", casAssertion);
            buildSamlResponse(response, request, authenticationContext, casAssertion, binding);
        } catch (final AuthenticationException e) {
            LOGGER.error(e.getMessage(), e);
            val error = e.getHandlerErrors().values()
                .stream()
                .map(Throwable::getMessage)
                .filter(Objects::nonNull)
                .collect(Collectors.joining(","));
            buildEcpFaultResponse(response, request, Pair.of(authnRequest, error));
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
            buildEcpFaultResponse(response, request, Pair.of(authnRequest, e.getMessage()));
        }
    }
1216802
public boolean send()
	{
		assert sentRequests == null;
		sentRequests = new ArrayList<RequestCallInfo>();

		// add prepended requests,
		addPrependedRequests( sentRequests );

		// add requests to send
		while( !requestsToSend.isEmpty() )
			sentRequests.add( requestsToSend.remove( 0 ) );

		// add appended requests
		addAppendedRequests( sentRequests );

		// prepare payload
		JSONArray payload = createPayload();

		RequestBuilder builderPost = buildMultipart( "payload", payload.toString() );

		nbSentBytes += builderPost.getRequestData().length();

		try
		{
			sentRequest = builderPost.send();
		}
		catch( RequestException e )
		{
			callback.error( RPCErrorCodes.ERROR_REQUEST_SEND, e, this );
			return false;
		}

		callback.sent( this );

		return true;
	}
529653
def _send_http_request(self, xml_request):
        
        headers = {"Host": self._host, "Content-Type": "text/xml", "Recipient": self._storage}
        try: # Retry once if failed in case the socket has just gone bad.
            self._connection.request("POST", self._selector_url, xml_request, headers)
            response = self._connection.getresponse()
        except (httplib.CannotSendRequest, httplib.BadStatusLine):
            Debug.warn("\nRestarting socket, resending message!")
            self._open_connection()
            self._connection.request("POST", self._selector_url, xml_request, headers)
            response = self._connection.getresponse()
        data = response.read()
        return data
2030
def send_request
      nameserver = @nameservers.shift
      @nameservers << nameserver # rotate them
      begin
        @socket.send request_message, 0, @nameservers.first, DNS_PORT
      rescue Errno::EHOSTUNREACH # TODO figure out why it has to be wrapper here, when the other wrapper should be wrapping this one!
      end
    end
1218920
public void doLogout(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        if (!common.checkPost(request, response)) return;
        request.getSession().removeAttribute("logged-in-username");
        response.sendRedirect("/");
    }
1327618
public void doGet (HttpServletRequest request,
			HttpServletResponse response)
	throws ServletException, IOException
	{
		String toAddr = request.getParameter("to");
		String fromAddr = request.getParameter("from");
		
		String bye = request.getParameter("bye");
		


		URI to = toAddr==null? null : sipFactory.createAddress(toAddr).getURI();
		URI from = fromAddr==null? null : sipFactory.createAddress(fromAddr).getURI();  
		
		
		SipApplicationSession appSession = 
        	((ConvergedHttpSession)request.getSession()).getApplicationSession();
		
		if(bye != null) {
			Iterator i = appSession.getSessions();
			while(i.hasNext()) {
				SipSession s = (SipSession) i.next();
				s.createRequest("BYE").send();
			}
			
		}
		
		appSession.setAttribute("setFromHttpServlet", appSession.getId());
		
		if(to != null && from != null)
		{

			SipServletRequest req = sipFactory.createRequest(appSession, "INVITE", from, to);

			// Set some attribute
			req.getSession().setAttribute("SecondPartyAddress", sipFactory.createAddress(fromAddr));

			logger.info("Sending request" + req);
			// Send the INVITE request            
			req.send();
		}

		// Write the output html
		PrintWriter	out;
		response.setContentType("text/html");
		out = response.getWriter();

		// Just redirect to the index
		out.println("<HTML><META HTTP-EQUIV=\"Refresh\"CONTENT=\"0; URL=index.jsp\"><HEAD><TITLE></HTML>");
		out.close();
	}
502681
public void doPost (HttpServletRequest request, HttpServletResponse response)
    		throws ServletException, IOException {
        String alertId = request.getParameter("alertId");
        String tel = request.getParameter("tel");
        String alertText = request.getParameter("alertText");        
        if(alertText == null || alertText.length() < 1) {
	        // Get the content of the request as the text to parse
	        byte[] content = new byte[request.getContentLength()];
	        request.getInputStream().read(content,0, request.getContentLength());        
	        alertText = new String(content); 	        
        }
        if(logger.isInfoEnabled()) {
        	logger.info("Got an alert : \n alertID : " + alertId + " \n tel : " + tel + " \n text : " +alertText);
        }
        // 
        try {
        	Properties jndiProps = new Properties();			
			Context initCtx = new InitialContext(jndiProps);
			// Commented out since the preferred way is through SMS Servlets
//        	SleeConnectionFactory factory = (SleeConnectionFactory) initCtx.lookup("java:/MobicentsConnectionFactory");
//        	
//			SleeConnection conn1 = factory.getConnection();
//			ExternalActivityHandle handle = conn1.createActivityHandle();
//
//			EventTypeID requestType = conn1.getEventTypeID(
//					EVENT_TYPE,
//					"org.mobicents", "1.0");
//			SmsAlertingCustomEvent smsAlertingCustomEvent = new SmsAlertingCustomEvent(alertId, tel, alertText);
//			
//			conn1.fireEvent(smsAlertingCustomEvent, requestType, handle, null);
//			conn1.close();
		} catch (Exception e) {
			logger.error("unexpected exception while firing the event " + EVENT_TYPE + " into jslee", e);
		}	
        
        sendHttpResponse(response, OK_BODY);
    }
238182
@Override
    protected boolean performRequest() {

        SocketChannel sc = null;
        boolean closeOnError = false;

        // If we were woken up because we have work to do, do it.
        Set<SelectionKey> keySet = this.selector.selectedKeys();
        Iterator<SelectionKey> keyIterator = keySet.iterator();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "performRequest - processing " + keySet.size() + " items");
        }

        while (keyIterator.hasNext()) {
            closeOnError = false;

            // If we get exceptions repeatedly, we may need to take a break for a number of reasons
            if (numExceptions >= 3100) {
                // if we don't recover after 290 more seconds, wait for 10 minutes
                if (pauseAccept()) {
                    resetExceptions(); // clear exceptions if we weren't interrupted
                }
                continue;
            } else if (numExceptions >= 200) {
                // if we get exceptions repeatedly, wait a tenth to give
                // other threads some time. It should take about 10 seconds for
                // us to get up to 200 exceptions (via trace analysis).
                if (numExceptions == 1500) {
                    FFDCFilter.processException(new Exception("TCP channel has received 1500 exceptions in a row on the accept selector"),
                                                getClass().getName(), "101", this);
                }
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ie) {
                    // ignore it
                }
            }

            // PK40415 - change audit handling of errors
            SelectionKey key = keyIterator.next();
            TCPPort endPoint = (TCPPort) key.attachment();
            TCPChannel tcpChannel = endPoint.getTCPChannel();

            try {
                // safe remove from set while iterating
                keyIterator.remove();

                // perform accept
                ServerSocketChannel serverSocketChannel = (ServerSocketChannel) key.channel();

                try {
                    sc = serverSocketChannel.accept();

                    // Configure all inbound channels to be non-blocking
                    if (sc != null) {
                        sc.configureBlocking(false);
                    }

                } catch (IOException ioe) {
                    incrementExceptions();
                    this.numAcceptIOExceptions++;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                        Tr.event(this, tc, "TCP Channel: " + tcpChannel.getExternalName() + " caught IOException doing accept: " + ioe + " total=" + numExceptions + " count="
                                           + numAcceptIOExceptions);
                    }
                    // Since we could be monitoring several serverSocketChannels, we need
                    // to continue processing even though we got an IOException on this
                    // serverSocketChannel.
                    continue;
                }

                // sometimes the accept can return null. This seems to happen when
                // there is a network problem, and we got notified it was ready to
                // accept, but when we went to do the accept we couldn't complete the accept. If
                // this happens, just skip this and go on
                if (sc == null) {
                    incrementExceptions();
                    this.numAcceptNulls++;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                        Tr.event(this, tc, "TCP Channel: " + tcpChannel.getExternalName() + " accept() returned null, total=" + numExceptions + " count=" + numAcceptNulls);
                    }
                    continue;
                }

                Socket socket = sc.socket();
                if (!testSocket(sc)) {
                    continue;
                }
                closeOnError = true;

                if (!tcpChannel.verifyConnection(socket)) {
                    closeSocketChannel(sc);

                    // if we made it this far, then the accept worked without exceptions
                    if (0 < this.numExceptions) {
                        resetExceptions();
                    }
                    continue;
                }

                SocketIOChannel ioSocket = null;
                try {
                    ioSocket = tcpChannel.createInboundSocketIOChannel(sc);
                } catch (IOException ioe) {
                    // no FFDC required
                    incrementExceptions();
                    this.numConfigureIOExceptions++;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                        Tr.event(this, tc, "IOException caught while configuring socket: " + ioe + ", total=" + numExceptions + " count=" + numConfigureIOExceptions);
                    }
                    closeSocketChannel(sc);
                    continue;
                }
                endPoint.processNewConnection(ioSocket);

            } catch (CancelledKeyException cke) {
                // no FFDC required
                // Should only get this if the socket was closed. Therefore
                // log error and continue processing
                incrementExceptions();
                this.numCancelledKeys++;
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(this, tc, "Cancelled key exception found, cke=" + cke + " total=" + numExceptions + " count=" + numCancelledKeys);
                }
                continue;
            } catch (Throwable t) {
                // don't leak sockets if we can't proceed after the accept
                if (closeOnError) {
                    closeSocketChannel(sc);
                }
                // the catcher of the RTE will do the FFDC
                throw new RuntimeException(t);
            }

            // if we made it this far, then the accept worked without exceptions
            if (0 < this.numExceptions) {
                resetExceptions();
            }
        } // end-while
        return false;
    }
945628
protected Response request (String req)
        throws IOException
    {
        System.err.println("REQ:" + req);

        // send the request to the server
        _out.println(req);
        _out.flush();

        // now read the response
        String rspstr = _in.readLine();
        // if they closed the connection on us, we should deal
        if (rspstr == null) {
            throw new EOFException();
        }
        System.err.println("RSP:" + rspstr);

        // parse the response
        Response rsp = new Response();
        String codestr = rspstr;

        // assume the response is just a code unless we see a space
        int sidx = rspstr.indexOf(" ");
        if (sidx != -1) {
            codestr = rspstr.substring(0, sidx);
            rsp.message = rspstr.substring(sidx+1);
        }

        try {
            rsp.code = Integer.parseInt(codestr);
        } catch (NumberFormatException nfe) {
            rsp.code = 599;
            rsp.message = "Unparseable response";
        }

        return rsp;
    }
805540
protected void handleJwtRequest(HttpServletRequest request, HttpServletResponse response,
			ServletContext servletContext, JwtConfig jwtConfig, EndpointType endpointType) throws IOException {
		if (jwtConfig == null) {
			if (tc.isDebugEnabled()) {
				Tr.debug(tc, "No JwtConfig object provided");
			}
			return;
		}
		switch (endpointType) {
		case jwk:
			processJWKRequest(response, jwtConfig);
			return;
		case token:
			try {
				if (!isTransportSecure(request)) {
					String url = request.getRequestURL().toString();
					Tr.error(tc, "SECURITY.JWT.ERROR.WRONG.HTTP.SCHEME", new Object[] { url });
					response.sendError(HttpServletResponse.SC_NOT_FOUND,
							Tr.formatMessage(tc, "SECURITY.JWT.ERROR.WRONG.HTTP.SCHEME", new Object[] { url }));
					return;
				}

				boolean result = request.authenticate(response);
				if (tc.isDebugEnabled()) {
					Tr.debug(tc, "request.authenticate result: " + result);
				}
				// if false, then not authenticated,
				// a 401 w. auth challenge will be sent back and
				// the response will be committed.
				// Requester can then try again with creds on a new request.
				if (result == false) {
					return;
				}
			} catch (ServletException e) {
				// ffdc
				return;
			}
			processTokenRequest(response, jwtConfig);
			return;
		default:
			break;
		}
	}
680074
private void sendEmptyRequest() {
        assertUnlocked();
        // Send an empty request
        LOG.finest("Sending empty request");
        try {
            send(ComposableBody.builder().build());
        } catch (BOSHException boshx) {
            dispose(boshx);
        }
    }
205879
public void sendResponse(Response arg0) throws SipException, InvalidArgumentException {

        validateWrappedTransaction();

        final Dialog d = wrappedTransaction.getDialog();
        if (d != null) {
            final DialogWrapper dw = ra.getDialogWrapper(d);
            if (dw != null) {
                final int statusCode = arg0.getStatusCode();
                if (this.getRequest().getMethod().equals(Request.CANCEL) && (statusCode < 300 && statusCode > 199) && dw.getState() == null) {
                    dw.delete();
                } else if (d.getLocalTag() == null) {
                    // a new dialog which local tag is not yet known by jain sip stack, add the tag to the response 
                    try {
                        ((ToHeader) arg0.getHeader(ToHeader.NAME)).setTag(dw.getLocalTag());
                    } catch (ParseException e) {
                        throw new SipException(e.getMessage(), e);
                    }
                }
            }
        }

        if (tracer.isInfoEnabled()) {
            tracer.info(toString() + " sending response:\n" + arg0);
        }
        wrappedTransaction.sendResponse(arg0);
    }