Send an extension message and return the response. This is for advanced
use only.

@param request
String
@param requestData
byte[]
@return SftpMessage
@throws SshException
@throws SftpStatusException
328501
public SftpMessage sendExtensionMessage(String request, byte[] requestData)
			throws SshException, SftpStatusException {

		try {
			UnsignedInteger32 id = nextRequestId();
			Packet packet = createPacket();
			packet.write(SSH_FXP_EXTENDED);
			packet.writeUINT32(id);
			packet.writeString(request);

			sendMessage(packet);

			return getResponse(id);
		} catch (IOException ex) {
			throw new SshException(SshException.INTERNAL_ERROR, ex);
		}
	}
223426
protected HttpResponse sendPayload(HttpEntityEnclosingRequestBase request, byte[] payload, HttpHost proxy) {
    HttpResponse response = null;
    try {
      HttpClient httpclient = new DefaultHttpClient();
      if(proxy != null) {
        httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
      }
      request.setEntity(new ByteArrayEntity(payload));
      log(request);
      response = httpclient.execute(request);
    } catch(IOException ioe) {
      throw new EFhirClientException("Error sending HTTP Post/Put Payload", ioe);
    }
    return response;
  }
492863
protected HttpResponse sendPayload(HttpEntityEnclosingRequestBase request, byte[] payload) {
    HttpResponse response = null;
    try {
      log(request);
      HttpClient httpclient = new DefaultHttpClient();
      request.setEntity(new ByteArrayEntity(payload));
      response = httpclient.execute(request);
      log(response);
    } catch(IOException ioe) {
      throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe);
    }
    return response;
  }
189538
protected function sendRequest(array $requestData): TransferInterface
    {
        $response = $this->adapter->sendRequest($requestData);

        return $this->converter->toTransactionResponseTransfer($response);
    }
789133
public byte[] nextMessage() throws SshException {
		if (Log.isDebugEnabled()) {
			if (verbose) {
				Log.debug(this, "transport next message");
			}
		}
		synchronized (transportIn) {

			byte[] msg;

			do {
				msg = readMessage();
			} while (processMessage(msg));
			return msg;
		}

	}
1072905
function send(conversationId, message, data, fileName, fileType, fileContent) {
  const form = new FormData()
  form.append('message', message)
  if (data != null) {
    form.append('data', data)
  }

  if (fileName != null) {
    form.append('attachment', fileContent, {
      filename: fileName,
      contentType: fileType,
      knownLength: fileContent.length,
    })
  }

  return agentRequest(
    'post',
    `/agent/v4/stream/${conversationId}/message/create`,
    'MessagesClient/sendMessage',
    form
  )
}
1253171
def request(command, messages)
      response = StringIO.new String.new(""), "w"
      response.set_encoding "ASCII-8BIT"
      status   = -1
      version  = 0
      length   = 0
      message  = Riddle.encode(Array(messages).join(""), 'ASCII-8BIT')

      connect do |socket|
        case command
        when :search
          if Versions[command] >= 0x118
            socket.send request_header(command, message.length) +
              [0, messages.length].pack('NN') + message, 0
          else
            socket.send request_header(command, message.length) +
              [messages.length].pack('N') + message, 0
          end
        when :status
          socket.send request_header(command, message.length), 0
        else
          socket.send request_header(command, message.length) + message, 0
        end

        header = socket.recv(8)
        status, version, length = header.unpack('n2N')

        while response.length < (length || 0)
          part = socket.recv(length - response.length)

          # will return 0 bytes if remote side closed TCP connection, e.g, searchd segfaulted.
          break if part.length == 0 && socket.is_a?(TCPSocket)

          response << part if part
        end
      end

      response = response.string

      if response.empty? || response.length != length
        raise ResponseError, "No response from searchd (status: #{status}, version: #{version})"
      end

      case status
      when Statuses[:ok]
        if version < Versions[command]
          puts format("searchd command v.%d.%d older than client (v.%d.%d)",
            version >> 8, version & 0xff,
            Versions[command] >> 8, Versions[command] & 0xff)
        end
        response
      when Statuses[:warning]
        length = response[0, 4].unpack('N*').first
        puts response[4, length]
        response[4 + length, response.length - 4 - length]
      when Statuses[:error], Statuses[:retry]
        message = response[4, response.length - 4]
        klass = message[/out of bounds/] ? OutOfBoundsError : ResponseError
        raise klass, "searchd error (status: #{status}): #{message}"
      else
        raise ResponseError, "Unknown searchd error (status: #{status})"
      end
    end
134223
private HttpRequest createHttpRequest(MessageContext msgContext)
      throws SOAPException, IOException {
    Message requestMessage =
        Preconditions.checkNotNull(
            msgContext.getRequestMessage(), "Null request message on message context");
    
    // Construct the output stream.
    String contentType = requestMessage.getContentType(msgContext.getSOAPConstants());
    ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);

    if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
      logger.debug("Compressing request");
      try (GZIPOutputStream gzipOs = new GZIPOutputStream(bos, BUFFER_SIZE)) {
        requestMessage.writeTo(gzipOs);
      }
    } else {
      logger.debug("Not compressing request");
      requestMessage.writeTo(bos);
    }

    HttpRequest httpRequest =
        requestFactory.buildPostRequest(
            new GenericUrl(msgContext.getStrProp(MessageContext.TRANS_URL)),
            new ByteArrayContent(contentType, bos.toByteArray()));

    int timeoutMillis = msgContext.getTimeout();
    if (timeoutMillis >= 0) {
      logger.debug("Setting read and connect timeout to {} millis", timeoutMillis);
      // These are not the same, but MessageContext has only one definition of timeout.
      httpRequest.setReadTimeout(timeoutMillis);
      httpRequest.setConnectTimeout(timeoutMillis);
    }

    // Copy the request headers from the message context to the post request.
    setHttpRequestHeaders(msgContext, httpRequest);

    return httpRequest;
  }
1125738
public int authenticate(AuthenticationClient auth, String servicename)
			throws SshException {
		try {
			auth.authenticate(this, servicename);
			readMessage();
			transport
					.disconnect(TransportProtocol.PROTOCOL_ERROR,
							"Unexpected response received from Authentication Protocol");
			throw new SshException(
					"Unexpected response received from Authentication Protocol",
					SshException.PROTOCOL_VIOLATION);
		} catch (AuthenticationResult result) {
			state = result.getResult();
			if (state == SshAuthentication.COMPLETE)
				transport.completedAuthentication();
			return state;
		}
	}
81626
public void sendForm(HttpServletRequest req, HttpServletResponse res, String strReceiveMessage, Properties properties)
		throws ServletException, IOException
	{
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
		out.write("<html>" + RETURN +
						"<head>" + RETURN +
						"<title>" + this.getTitle() + "</title>" + RETURN +
						"</head>" + RETURN +
						"<body>" + RETURN +
						"<center><b>" + this.getTitle() + "</b></center><p />" + RETURN);

		String strServletPath = null;
		try	{
			strServletPath = req.getRequestURI();	//Path();
		} catch (Exception ex)
		{
			strServletPath = null;
		}
		if (strServletPath == null)
			strServletPath = "servlet/" + UploadServlet.class.getName();	// Never
//strServletPath = "http://localhost/jbackup/servlet/com.tourgeek.jbackup.Servlet";

		out.write(strReceiveMessage);		// Status of previous upload
		out.write("<p /><form action=\"" + strServletPath + "\"");
		out.write(" method=\"post\"" + RETURN);
		out.write(" enctype=\"multipart/form-data\">" + RETURN);
// TARGET=_top
//		out.write(" ACTION="http://www45.visto.com/?uid=219979&service=fileaccess&method=upload&nextpage=fa%3Dafter_upload.html&errorpage=fa_upload@.html&overwritepage=fa=upload_replace_dialog.html">
//		out.write("What is your name? <INPUT TYPE=TEXT NAME=submitter> <BR>" + RETURN);
		String strFormHTML = this.getFormHTML();
		if ((strFormHTML != null) && (strFormHTML.length() > 0))
			out.write(strFormHTML);
		out.write("Which file to upload? <input type=\"file\" name=\"file\" />" + RETURN);
		this.writeAfterHTML(out, req, properties);
		out.write("<input type=\"submit\" value=\"upload\" />" + RETURN);
		out.write("</form></p>" + RETURN);
		
		out.write("</body>" + RETURN +
						"</html>" + RETURN);
	}
629720
public final void send (final ProtocolDataUnit protocolDataUnit) throws InternetSCSIException {

        try {
            senderReceiver.sendOverWire(protocolDataUnit);
        } catch (IOException e) {
            throw new InternetSCSIException(e);
        } catch (InterruptedException e) {
            throw new InternetSCSIException(e);
        }
    }
366742
final public function sendRequest(Request $request, $callback)
    {
        if ($this->enabled->get() == false) {
            return;
        }

        $this->webaccess->request(
            self::dedimaniaUrl,
            [[$this, "process"], $callback],
            $request->getXml(),
            true,
            600,
            3,
            5,
            'eXpansion server controller',
            'application/x-www-form-urlencoded; charset=UTF-8'
        );
    }
109865
public BaseMessage sendMessageRequest(BaseMessage messageOut)
    {
        TrxMessageHeader trxMessageHeader = (TrxMessageHeader)messageOut.getMessageHeader();
        String strTrxID = (String)trxMessageHeader.get(TrxMessageHeader.LOG_TRX_ID);
        try {
            // Create a fake Incoming message with this message's external data
            String strMessageCode = (String)trxMessageHeader.get(LocalMessageTransport.LOCAL_PROCESSOR);
            TrxMessageHeader trxMessageHeaderIn = new TrxMessageHeader(null, null);
            trxMessageHeaderIn.put(TrxMessageHeader.MESSAGE_CODE, strMessageCode);

            BaseMessage messageIn = new TreeMessage(trxMessageHeaderIn, null);
            new ExternalMapTrxMessageIn(messageIn, messageOut.getExternalMessage().getRawData());
            // And fake send it by calling this:
            BaseMessage messageReply = this.processIncomingMessage(messageIn, null);
            this.logMessage(strTrxID, messageOut, MessageInfoTypeModel.REQUEST, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.SENT, null, null);

            this.setupReplyMessage(messageReply, null, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT);
            int iErrorCode = this.convertToExternal(messageReply, null);
            if (iErrorCode != DBConstants.NORMAL_RETURN)
            {
                String strMessageDescription = this.getTask().getLastError(iErrorCode);
                if ((strMessageDescription == null) || (strMessageDescription.length() == 0))
                    strMessageDescription = "Error converting to external format";
                messageReply = BaseMessageProcessor.processErrorMessage(this, messageOut, strMessageDescription);
            }

            return messageReply;
        } catch (Throwable ex)  {
            ex.printStackTrace();
            String strError = "Error in processing or replying to a message";
            Utility.getLogger().warning(strError);
            this.logMessage(strTrxID, null, MessageInfoTypeModel.REQUEST, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.ERROR, strError, null);
            return BaseMessageProcessor.processErrorMessage(this, messageOut, strError);
        }
    }
785108
private RESTResponse sendAndReceive(HttpMethod          method,
                                        String              uri,
                                        Map<String, String> headers,
                                        byte[]              body) throws IOException {
        // Add standard headers
        assert headers != null;
        headers.put(HttpDefs.HOST, m_host);
        headers.put(HttpDefs.ACCEPT, m_acceptFormat.toString());
        headers.put(HttpDefs.CONTENT_LENGTH, Integer.toString(body == null ? 0 : body.length));
        if (m_bCompress) {
            headers.put(HttpDefs.ACCEPT_ENCODING, "gzip");
        }
        if (m_credentials != null) {
            String authString =
                "Basic " + Utils.base64FromString(m_credentials.getUserid() + ":" + m_credentials.getPassword());
            headers.put("Authorization", authString);
        }
        
        // Form the message header.
        StringBuilder buffer = new StringBuilder();
        buffer.append(method.toString());
        buffer.append(" ");
        buffer.append(addTenantParam(uri));
        buffer.append(" HTTP/1.1\r\n");
        for (String name : headers.keySet()) {
            buffer.append(name);
            buffer.append(": ");
            buffer.append(headers.get(name));
            buffer.append("\r\n");
        }
        buffer.append("\r\n");

        m_logger.debug("Sending request to uri '{}'; message length={}",
                       uri, headers.get(HttpDefs.CONTENT_LENGTH));
        return sendAndReceive(buffer.toString(), body);
    }
746843
public RequestResponse setRequestData(Object requestData) {
        this.requestData = requestData;
        requestJson = requestData != null
                ? (requestData instanceof JsonNode ? (JsonNode) requestData
                        : SerializationUtils.toJson(requestData))
                : null;
        return this;
    }
654278
public static Sftp createSftp(String sshHost, int sshPort, String sshUser, String sshPass) {
		return new Sftp(sshHost, sshPort, sshUser, sshPass);
	}
1369029
public static HttpMessage fromRequestData(final String requestData) {
        try (final BufferedReader reader = new BufferedReader(new StringReader(requestData))) {
            final HttpMessage request = new HttpMessage();

            final String[] requestLine = reader.readLine().split("\\s");
            if (requestLine.length > 0) {
                request.method(HttpMethod.valueOf(requestLine[0]));
            }

            if (requestLine.length > 1) {
                request.uri(requestLine[1]);
            }

            if (requestLine.length > 2) {
                request.version(requestLine[2]);
            }

            return parseHttpMessage(reader, request);
        } catch (final IOException e) {
            throw new CitrusRuntimeException("Failed to parse Http raw request data", e);
        }
    }