Pushes request data to the open http connection

@param connection - the open connection of the http call
@param request    - the parameters to be passed to the endpoint for the service
call
@param file       - the file to upload with the request
963674
private void writeMultipartDataRequest(HttpURLConnection connection, Request request, File file) {
        try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
            wr.writeBytes(NEWLINE);
            if (request != null && request.getJsonPayload() != null) {
                wr.writeBytes(NEWLINE + "--" + BOUNDARY + NEWLINE);
                wr.writeBytes("Content-Disposition: form-data; name=\"data\"");
                wr.writeBytes(NEWLINE + NEWLINE);
                wr.writeBytes(request.getJsonPayload().toString());
            }
            if (request != null && request.getMultipartData() != null) {
                for (String param : request.getMultipartData().keySet()) {
                    wr.writeBytes(NEWLINE + "--" + BOUNDARY + NEWLINE);
                    wr.writeBytes("Content-Disposition: form-data; name=\"" + param + "\"");
                    wr.writeBytes(NEWLINE + NEWLINE);
                    wr.writeBytes(request.getMultipartData().get(param).toString());
                }
            }
            if (file != null) {
                if (!file.exists()) {
                    log.error("Unable to upload file with http call, as file can't be found: " + file.getName());
                } else {
                    wr.writeBytes(NEWLINE + "--" + BOUNDARY + NEWLINE);
                    wr.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"");
                    wr.writeBytes(NEWLINE);
                    wr.writeBytes("Content-Type: " + Files.probeContentType(file.toPath()));
                    wr.writeBytes(NEWLINE + NEWLINE);
                    byte[] bytes = Files.readAllBytes(file.toPath());
                    wr.write(bytes);
                }
            }
            wr.writeBytes(NEWLINE + "--" + BOUNDARY + "--" + NEWLINE);
            wr.flush();
        } catch (IOException e) {
            log.error(e);
        }
    }
1298722
public void releaseRequest(HttpRequestMessageImpl request) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "releaseRequest: " + request);
        }
        this.reqPool.put(request);
    }
994726
public void prepareToConnect(Request request) {
    if (this.request != null) {
      if (sameConnection(this.request.url(), request.url()) && exchangeFinder.hasRouteToTry()) {
        return; // Already ready.
      }
      if (exchange != null) throw new IllegalStateException();

      if (exchangeFinder != null) {
        maybeReleaseConnection(null, true);
        exchangeFinder = null;
      }
    }

    this.request = request;
    this.exchangeFinder = new ExchangeFinder(this, connectionPool, createAddress(request.url()),
        call, eventListener);
  }
967616
protected void customizeConnection(String pathInContext, String pathParams, HttpRequest request, URLConnection connection) throws IOException
    {
    }
541279
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tech = request.getParameter(PARAMETER_TECH);
        String workspaceId = request.getParameter(PARAMETER_WORKSPACE);    //specify the unique workspace directory to upload the file(s) to.    
        Collection<Part> filePartCollection = request.getParts();
        
        String serverHostPort = request.getRequestURL().toString().replace(request.getRequestURI(), "");
        int schemeLength = request.getScheme().toString().length();
        String internalHostPort = "http" + serverHostPort.substring(schemeLength);
        log.log(Level.FINER, "serverHostPort : " + serverHostPort);
        final ServiceConnector serviceConnector = new ServiceConnector(serverHostPort, internalHostPort);
        HashMap<Part, String> fileNames = new HashMap<Part, String>();
        if(!isValidRequest(request, response, tech, workspaceId, filePartCollection, serviceConnector, fileNames)){
            return;
        }

        Service techService = serviceConnector.getServiceObjectFromId(tech);
        String techDirPath = StarterUtil.getWorkspaceDir(workspaceId) + "/" + techService.getId();
        File techDir = new File(techDirPath);
        if(techDir.exists() && techDir.isDirectory() && "true".equalsIgnoreCase(request.getParameter(PARAMETER_CLEANUP))){
            FileUtils.cleanDirectory(techDir);
            log.log(Level.FINER, "Cleaned up tech workspace directory : " + techDirPath);
        }

        for (Part filePart : filePartCollection){
            if(!techDir.exists()){
                FileUtils.forceMkdir(techDir);
                log.log(Level.FINER, "Created tech directory :" + techDirPath);
            }
            
            String filePath = techDirPath + "/" + fileNames.get(filePart);
            log.log(Level.FINER, "File path : " + filePath);
            File uploadedFile = new File(filePath);

            Files.copy(filePart.getInputStream(), uploadedFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
            log.log(Level.FINE, "Copied file to " + filePath);    
        }

        if("true".equalsIgnoreCase(request.getParameter(PARAMETER_PROCESS))){
            // Process uploaded file(s)
            String processResult = serviceConnector.processUploadedFiles(techService, techDirPath);
            if(!processResult.equalsIgnoreCase("success")){
                log.log(Level.INFO, "Error processing the files uploaded to " + techDirPath + " : Result=" + processResult);
                response.sendError(500, processResult);
                return;
            }
            log.log(Level.FINE, "Processed the files uploaded to " + techDirPath);    
        }

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("success");
        out.close();
    }
1109898
private <T extends Request, U> void sendRequest(T request, BiFunction<Request, Connection, CompletableFuture<U>> sender, Connection connection, Throwable error, CompletableFuture<U> future) {
    if (open) {
      if (error == null) {
        if (connection != null) {
          LOGGER.trace("{} - Sending {}", id, request);
          sender.apply(request, connection).whenComplete((r, e) -> {
            if (e != null || r != null) {
              handleResponse(request, sender, connection, (Response) r, e, future);
            } else {
              future.complete(null);
            }
          });
        } else {
          future.completeExceptionally(new ConnectException("Failed to connect to the cluster"));
        }
      } else {
        LOGGER.trace("{} - Resending {}: {}", id, request, error);
        resendRequest(error, request, sender, connection, future);
      }
    }
  }
502375
function onConnection() {
  var endpoint = new http2.Endpoint(log, 'CLIENT', {});
  endpoint.pipe(socket).pipe(endpoint);

  // Sending request
  var stream = endpoint.createStream();
  stream.headers({
    ':method': 'GET',
    ':scheme': url.protocol.slice(0, url.protocol.length - 1),
    ':authority': url.hostname,
    ':path': url.path + (url.hash || '')
  });

  // Receiving push streams
  stream.on('promise', function(push_stream, req_headers) {
    var filename = path.join(__dirname, '/push-' + push_count);
    push_count += 1;
    console.error('Receiving pushed resource: ' + req_headers[':path'] + ' -> ' + filename);
    push_stream.pipe(fs.createWriteStream(filename)).on('finish', finish);
  });

  // Receiving the response body
  stream.pipe(process.stdout);
  stream.on('end', finish);
}
225719
public void addConnection(ServerSentEventConnection connection) {
        Objects.requireNonNull(connection, Required.CONNECTION.toString());

        final String url = RequestUtils.getServerSentEventURL(connection);
        Set<ServerSentEventConnection> uriConnections = getConnections(url);
        if (uriConnections == null) {
            uriConnections = new HashSet<>();
            uriConnections.add(connection);
        } else {
            uriConnections.add(connection);
        }
        setConnections(url, uriConnections);
    }
1038911
public String uploadFile(File file) throws IOException {
        HttpPost post = null;
        try {
            // prepare the post method
            post = new HttpPost(getUploadURL());
            post.getParams().setParameter("Connection", "Keep-Alive");

            // add the file part
            MultipartEntity entity = new MultipartEntity();
            entity.addPart("file", new FileBody(file));
            post.setEntity(entity);

            // execute and get the response
            HttpResponse response = getHttpClient().execute(post);
            int responseCode = response.getStatusLine().getStatusCode();
            String body = null;
            try {
                if (response.getEntity() != null) {
                    body = EntityUtils.toString(response.getEntity());
                }
            } catch (Exception e) {
                logger.warn("Error reading response body", e);
            }
            if (body == null) {
                body = "[empty response body]";
            }
            body = body.trim();
            if (responseCode != HttpStatus.SC_CREATED) {
                throw new IOException("Upload failed: "
                        + response.getStatusLine().getReasonPhrase()
                        + ": " + replaceNewlines(body, " "));
            } else {
                return replaceNewlines(body, "");
            }
        } finally {
            if (post != null) {
                post.releaseConnection();
            }
        }
    }
1358668
private void setHeaders(HttpRequest req, HttpURLConnection connection) {
        if (logger.isDebugEnabled()) {
            logger.debug("Request: ");
            logger.debug(req.getMethod().name() + " ", req.getURL());
        }

        String authorizationHeader;
        if (req.getAuthorization() != null && (authorizationHeader = req.getAuthorization().getAuthorizationHeader(req)) != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Authorization: ", authorizationHeader.replaceAll(".", "*"));
            }
            connection.addRequestProperty("Authorization", authorizationHeader);
        }
        if (req.getRequestHeaders() != null) {
            for (String key : req.getRequestHeaders().keySet()) {
                connection.addRequestProperty(key, req.getRequestHeaders().get(key));
                logger.debug(key + ": " + req.getRequestHeaders().get(key));
            }
        }
    }
694657
public void service(ConnectionProtocol request)
  {
    RequestBaratine req = (RequestBaratine) request;
    
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();
    
    try {
      if (_webApp != null) {
        thread.setContextClassLoader(_webApp.classLoader());
      }
      
      for (RouteBaratine route : _routes) {
        if (route.service(req)) {
          return;
        }
      }
      
      if (_routes.length > 0) {
        req.halt(HttpStatus.METHOD_NOT_ALLOWED);
      }
      else {
        req.halt(HttpStatus.NOT_FOUND);
        
      }
    } finally {
      thread.setContextClassLoader(oldLoader);
    }
  }
440762
public void doWithRequest(
                    final ClientHttpRequest request
                    )
    throws IOException
    {
        HttpHeaders  headers = request.getHeaders();
        headers.setContentType( _mediaType );

        long  size = IoUtil.copy( _input, new OutputStreamWriter( request.getBody() ) );
        headers.setContentLength( size );
    }
414302
private void executeJoinRequest(JoinRequest joinRequest, Connection connection) {
        clusterServiceLock.lock();
        try {
            if (checkJoinRequest(joinRequest, connection)) {
                return;
            }

            if (!authenticate(joinRequest)) {
                return;
            }

            if (!validateJoinRequest(joinRequest, joinRequest.getAddress())) {
                return;
            }

            startJoinRequest(joinRequest.toMemberInfo());
        } finally {
            clusterServiceLock.unlock();
        }
    }
1029488
public void createFileUploadHandler(File file) {

		final String uuid = file.getProperty(GraphObject.id);

		uploads.put(uuid, new FileUploadHandler(file));

	}
910441
protected void sendConfigureRequest(Connection connection, MemberState member, ConfigureRequest request) {
    logger.trace("{} - Sending {} to {}", context.getCluster().member().address(), request, member.getMember().serverAddress());
    connection.<ConfigureRequest, ConfigureResponse>sendAndReceive(request).whenComplete((response, error) -> {
      context.checkThread();

      // Complete the configure to the member.
      member.completeConfigure();

      if (open) {
        if (error == null) {
          logger.trace("{} - Received {} from {}", context.getCluster().member().address(), response, member.getMember().serverAddress());
          handleConfigureResponse(member, request, response);
        } else {
          logger.warn("{} - Failed to configure {}", context.getCluster().member().address(), member.getMember().serverAddress());
          handleConfigureResponseFailure(member, request, error);
        }
      }
    });
  }
306536
public DatabaseConnectionRequest<T, U> setConnection(String connection) {
        request.addParameter(ParameterBuilder.CONNECTION_KEY, connection);
        return this;
    }
1036133
public void addConnection(RedisURI redisURI, CompletableFuture<StatefulRedisConnection<String, String>> connection) {
        connections.put(redisURI, connection);
    }