Handle a file action AJAX request.

@param request the request being processed
170978
protected void doHandleFileAjaxActionRequest(final Request request) {
		// Protect against client-side tampering of disabled components
		if (isDisabled()) {
			throw new SystemException("File widget is disabled.");
		}

		// Check for file id
		String fileId = request.getParameter(FILE_UPLOAD_ID_KEY);
		if (fileId == null) {
			throw new SystemException("No file id provided for ajax action.");
		}

		// Check valid file id
		FileWidgetUpload file = getFile(fileId);
		if (file == null) {
			throw new SystemException("Invalid file id [" + fileId + "].");
		}

		// Run the action
		final Action action = getFileAjaxAction();
		if (action == null) {
			throw new SystemException("No action set for file ajax action request.");
		}

		// Set the selected file id as the action object
		final ActionEvent event = new ActionEvent(this, "fileajax", fileId);
		Runnable later = new Runnable() {
			@Override
			public void run() {
				action.execute(event);
			}
		};

		invokeLater(later);
	}
1232747
@Override
	public void handleRequest(final Request request) {
		assertConfigured();

		//
		// Service the request for each row.
		//
		List beanList = getBeanList();
		HashSet rowIds = new HashSet(beanList.size());
		WComponent row = getRepeatedComponent();

		for (int i = 0; i < beanList.size(); i++) {
			Object rowData = beanList.get(i);
			rowIds.add(getRowId(rowData));

			// Each row has its own context. This is why we can reuse the same
			// WComponent instance for each row.
			UIContext rowContext = getRowContext(rowData, i);

			try {
				UIContextHolder.pushContext(rowContext);
				row.serviceRequest(request);
			} finally {
				UIContextHolder.popContext();
			}
		}

		cleanupStaleContexts(rowIds);
	}
554080
public void handleRequest(String request) {
        if (messageListener != null) {
            log.debug("Received Http request");
            messageListener.onInboundMessage(new RawMessage(request), null);
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Received Http request:" + NEWLINE + request);
            }
        }
    }
250131
def handle_request_files_upload(request):
    
    # FILES is a dictionary in Django but Ajax Upload gives the uploaded file
    # an ID based on a random number, so it cannot be guessed here in the code.
    # Rather than editing Ajax Upload to pass the ID in the querystring,
    # note that each upload is a separate request so FILES should only
    # have one entry.
    # Thus, we can just grab the first (and only) value in the dict.
    is_raw = False
    upload = list(request.FILES.values())[0]
    filename = upload.name
    return upload, filename, is_raw
888733
function onRequest(request, response) {
  var filename = path.join(__dirname, request.url);

  // Serving server.js from cache. Useful for microbenchmarks.
  if (request.url === cachedUrl) {
    if (response.push) {
      // Also push down the client js, since it's possible if the requester wants
      // one, they want both.
      var push = response.push('/client.js');
      push.writeHead(200);
      fs.createReadStream(path.join(__dirname, '/client.js')).pipe(push);
    }
    response.end(cachedFile);
  }

  // Reading file from disk if it exists and is safe.
  else if ((filename.indexOf(__dirname) === 0) && fs.existsSync(filename) && fs.statSync(filename).isFile()) {
    response.writeHead(200);
    var fileStream = fs.createReadStream(filename);
    fileStream.pipe(response);
    fileStream.on('finish',response.end);
  }

  // Example for testing large (boundary-sized) frames.
  else if (request.url === "/largeframe") {
    response.writeHead(200);
    var body = 'a';
    for (var i = 0; i < 14; i++) {
      body += body;
    }
    body = body + 'a';
    response.end(body);
  }

  // Otherwise responding with 404.
  else {
    response.writeHead(404);
    response.end();
  }
}
579909
private function handle($request)
    {
        $found = $this->fileMap->render($request->getPathToMatch());
        if (empty($found)) {
            return null;
        }
        if (is_resource($found[0])) {
            return $request->respond()->asFileContents($found[0], $found[1]);
        }
        if (is_string($found[0])) {
            return $request->respond()->asContents($found[0]);
        }
        return null;
    }
599087
public void deleteImage(DeleteImageRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getImageId(), "request imageId should not be empty.");
        InternalRequest internalRequest =
                this.createRequest(request, HttpMethodName.DELETE, IMAGE_PREFIX, request.getImageId());
        invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }
623300
public function handleFile(HTTPRequest $request)
    {
        $filename = $this->parseFilename($request);

        // Deny requests to private file
        if (!$this->isValidFilename($filename)) {
            return $this->httpError(400, "Invalid request");
        }

        // Pass through to backend
        return $this->getRouteHandler()->getResponseFor($filename);
    }
824097
private void handleSelectionRequest(final Request request) {
		String[] paramValue = request.getParameterValues(getId() + ".selected");

		if (paramValue == null) {
			paramValue = new String[0];
		}

		Map<List<Integer>, Object> pageRowKeys = getCurrentRowIndexAndKeys();

		String[] selectedRows = removeEmptyStrings(paramValue);
		Set<?> oldSelections = getSelectedRows();
		Set<Object> newSelections;

		boolean singleSelect = getSelectMode() == SelectMode.SINGLE;

		if (getTableModel().getRowCount() == 0) {
			newSelections = new HashSet<>();
			selectedRows = new String[0];
		} else if (getPaginationMode() == PaginationMode.NONE || getPaginationMode() == PaginationMode.CLIENT
				|| oldSelections == null || !isPaginated()) {
			newSelections = new HashSet<>(selectedRows.length);
		} else if (singleSelect && selectedRows.length > 0) {
			// For single-select, we need to remove the old entries
			newSelections = new HashSet<>(1);
		} else {
			// For multi-select, we need the entries for the current page only
			newSelections = (Set<Object>) new HashSet<>(oldSelections);
			newSelections.removeAll(pageRowKeys.values());
		}

		for (String selectedRow : selectedRows) {
			List<Integer> rowIndex = TableUtil.rowIndexStringToList(selectedRow);
			Object key = pageRowKeys.get(rowIndex);
			if (key == null) {
				continue;
			}
			newSelections.add(key);
			if (singleSelect) {
				break;
			}
		}

		setSelectedRows(newSelections);

		// If there is a selection change action specified, it may need to be fired
		Action selectionChangeAction = getSelectionChangeAction();

		if (selectionChangeAction != null && !newSelections.equals(oldSelections)) {
			selectionChangeAction.execute(new ActionEvent(this, SELECTION_ACTION_COMMAND));
		}
	}
1213450
@Override
	public void handleRequest(final Request request) {
		if (!isDisabled()) {
			final SelectToggleModel model = getComponentModel();
			String requestParam = request.getParameter(getId());

			final State newValue;
			if ("all".equals(requestParam)) {
				newValue = State.ALL;
			} else if ("none".equals(requestParam)) {
				newValue = State.NONE;
			} else if ("some".equals(requestParam)) {
				newValue = State.SOME;
			} else {
				newValue = model.state;
			}

			if (!newValue.equals(model.state)) {
				setState(newValue);
			}
			if (!model.clientSide && model.target != null && !State.SOME.equals(newValue)) {
				// We need to change the selections *after* all components
				// Have updated themselves from the request, as they may change
				// their values when their handleRequest methods are called.
				invokeLater(new Runnable() {
					@Override
					public void run() {
						setSelections(model.target, State.ALL.equals(newValue));
					}
				});
			}
		}
	}
659946
@Override
	public void handleRequest(final Request request) {
		if (isDisabled()) {
			// Protect against client-side tampering of disabled/read-only fields.
			return;
		}

		if (isMenuPresent(request)) {
			// If current ajax trigger, process menu for current selections
			if (AjaxHelper.isCurrentAjaxTrigger(this)) {
				WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, this);
				menu.handleRequest(request);

				// Execute associated action, if set
				final Action action = getAction();

				if (action != null) {
					final ActionEvent event = new ActionEvent(this, this.getActionCommand(),
							this.getActionObject());

					Runnable later = new Runnable() {
						@Override
						public void run() {
							action.execute(event);
						}
					};

					invokeLater(later);
				}
			}

			boolean openState = "true".equals(request.getParameter(getId() + ".open"));
			setOpen(openState);
		}
	}
103223
public function handleAction(FileManager $fileManager, Request $request, $action)
    {
        $response = new Response();
        try{
            $dir = $this->getFilePath($fileManager);
            $fileManager->setDir($dir);
            $fileManager->checkPath();
            if($request->getMethod() === 'POST') {
                $this->checkToken($request->get('token'));
            }
            switch($action){
                case FileManager::FILE_DELETE:
                    $fileManager->deleteFile();
                    break;
                case FileManager::FILE_MOVE:
                    $fileManager->moveFile();
                    break;
                case FileManager::FILE_EXTRACT:
                    $fileManager->extractZip();
                    break;
                case FileManager::FILE_RENAME:
                    $fileManager->renameFile();
                    break;
                case FileManager::FILE_NEW_DIR:
                    $fileManager->newDirectory();
                    break;
                case FileManager::FILE_COPY:
                case FileManager::FILE_CUT:
                    $this->copyFile($action);
                    break;
                case FileManager::FILE_PASTE:
                    $this->pasteFile();
                    break;
                case FileManager::FILE_INFO:
                    $response = new JsonResponse();
                    $response->setData(json_encode($fileManager->getCurrentFile()->toArray()));
                    break;
            }
        } catch(\Exception $e){
            $response->setContent($e->getMessage());
            $response->setStatusCode($e->getCode() == null ? 500 : $e->getCode());
        }
        return $response;
    }
274974
public void destroy(DestroyRequest request) {
    call(
      new PostRequest(path("destroy"))
        .setParam("id", request.getId())
        .setParam("organization", request.getOrganization())
        .setMediaType(MediaTypes.JSON)
    ).content();
  }
507013
public void execute(final AwsRequest request) {
    service.callFunction(
        Fields.EXECUTE_ACTION_NAME,
        Collections.singletonList(getRequestArgs(request)));
  }
492755
public static void processInputFileField(MultipartBody request, String fieldName, InputFile inputFile) {
        String fileId = inputFile.getFileID();
        if (fileId != null) {
            request.field(fieldName, fileId, false);
        } else if (inputFile.getInputStream() != null) {
            request.field(fieldName, new InputStreamBody(inputFile.getInputStream(), inputFile.getFileName()), true);
        } else { // assume file is not null (this is existing behaviour as of 1.5.1)
            request.field(fieldName, new FileContainer(inputFile), true);
        }
    }
957127
private void executeDownload(DownloadRequest request) {
    if (Thread.currentThread().isInterrupted()) {
      return;
    }

    Downloader downloader = request.downloader();
    RandomAccessFile raf = null;
    InputStream is = null;

    try {
      if (request.destinationFilePath() == null) {
        request.updateDestinationFilePath(downloader.detectFilename(request.uri()));
      }

      File file = new File(request.tempFilePath());
      raf = new RandomAccessFile(file, "rw");
      long breakpoint = file.length();
      long bytesWritten = 0;
      if (file.exists()) {
        /* set the range to continue the downloading */
        raf.seek(breakpoint);
        bytesWritten = breakpoint;
        logger.log(
            "Detect existed file with " + breakpoint + " bytes, start breakpoint downloading");
      }

      int statusCode = downloader.start(request.uri(), breakpoint);
      is = downloader.byteStream();
      if (statusCode != HTTP_OK && statusCode != HTTP_PARTIAL) {
        logger.log("Incorrect http code got: " + statusCode);
        throw new DownloadException(statusCode, "download fail");
      }

      long contentLength = downloader.contentLength();
      if (contentLength <= 0 && is == null) {
        throw new DownloadException(statusCode, "content length error");
      }
      boolean noContentLength = contentLength <= 0;
      contentLength += bytesWritten;

      updateStart(request, contentLength);
      logger.log("Start to download, content length: " + contentLength + " bytes");

      if (is != null) {
        byte[] buffer = new byte[BUFFER_SIZE];
        int length;

        while (true) {
          /* if the request has canceld, stop the downloading */
          if (Thread.currentThread().isInterrupted() || request.isCanceled()) {
            request.finish();
            return;
          }

          /* if current is not wifi and mobile network is not allowed, stop */
          if (request.allowedNetworkTypes() != 0
              && !Utils.isWifi(request.context())
              && (request.allowedNetworkTypes() & DownloadRequest.NETWORK_MOBILE) == 0) {
            throw new DownloadException(statusCode, "allow network error");
          }

          /* read data into buffer from input stream */
          length = readFromInputStream(buffer, is);
          long fileSize = raf.length();
          long totalBytes = noContentLength ? fileSize : contentLength;

          if (length == -1) {
            updateSuccess(request);
            return;
          } else if (length == Integer.MIN_VALUE) {
            throw new DownloadException(statusCode, "transfer data error");
          }

          bytesWritten += length;
          /* write buffer into local file */
          raf.write(buffer, 0, length);

          /* deliver progress callback */
          updateProgress(request, bytesWritten, totalBytes);
        }
      } else {
        throw new DownloadException(statusCode, "input stream error");
      }
    } catch (IOException e) {
      logger.log("Caught new exception: " + e.getMessage());

      if (e instanceof DownloadException) {
        DownloadException exception = (DownloadException) e;
        updateFailure(request, exception.getCode(), exception.getMessage());
      } else {
        updateFailure(request, 0, e.getMessage());
      }
    } finally {
      downloader.close();
      silentCloseFile(raf);
      silentCloseInputStream(is);
    }
  }
1286753
@Override
	public void handleRequest(final Request request) {
		if (plainBtn.isPressed()) {
			WMessages.getInstance(this).info("Plain button pressed.");
		}

		if (linkBtn.isPressed()) {
			WMessages.getInstance(this).info("Link button pressed.");
		}
	}