Judge the turning mode.
True means turn on, False is turn off.
If not present, Not supported.
Default implementation is check content is on/off for PUT method

@param req HttpRequest
490023
protected CompletionStage<Optional<Boolean>> mode(@SuppressWarnings("unused") ServiceRequestContext ctx,
                                                      HttpRequest req) {
        return req.aggregate()
                  .thenApply(AggregatedHttpMessage::content)
                  .thenApply(HttpData::toStringAscii)
                  .thenApply(content -> {
                      switch (Ascii.toUpperCase(content)) {
                          case "ON":
                              return Optional.of(true);
                          case "OFF":
                              return Optional.of(false);
                          default:
                              return Optional.empty();
                      }
                  });
    }
718803
public static boolean isEditableRequest(ServletRequest req) {

        boolean result = false;
        if (CmsHistoryResourceHandler.isHistoryRequest(req) || CmsJspTagEnableAde.isDirectEditDisabled(req)) {
            // don't display direct edit buttons on an historical resource
            result = false;
        } else {
            CmsFlexController controller = CmsFlexController.getController(req);
            CmsObject cms = controller.getCmsObject();
            result = !cms.getRequestContext().getCurrentProject().isOnlineProject()
                && !CmsResource.isTemporaryFileName(cms.getRequestContext().getUri());

        }
        return result;
    }
67792
function (/* event */) {
        if (!me.device.isFullscreen) {
            me.device.requestFullscreen();
        } else {
            me.device.exitFullscreen();
        }
        return false;
    }
1366602
def switch_on(self):
        """"""
        success = self.set_status(CONST.STATUS_ON_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_ON

        return success
433041
public void checkContentType(final HttpServletRequest request) {
    String reqpar = request.getParameter(getContentTypeRequestName());

    if (reqpar != null) {
      if (reqpar.equals("!")) {
        // Go back to unsticky content type
        setContentTypeSticky(false);
      } else {
        setContentType(reqpar);
        setContentTypeSticky(false);
      }
    }

    reqpar = request.getParameter(getContentTypeStickyRequestName());
    if (reqpar != null) {
      if (reqpar.equals("!")) {
        // Go back to unsticky content type
        setContentTypeSticky(false);
      } else {
        setContentType(reqpar);
        setContentTypeSticky(true);
      }
    }
  }
422615
@SuppressWarnings("null")
  private boolean accepts(SlingHttpServletRequest request) {
    return request.getMethod().equalsIgnoreCase(METHOD_GET)
        && request.getResource() != null
        && StringUtils.equals(request.getResource().getValueMap().get(JCR_PRIMARYTYPE, String.class), NT_FILE);
  }
1348176
def trigger_switch_all_to(request, switch):
    
    now = arrow.utcnow().to(settings.TIME_ZONE).format('YYYY-MM-DD HH:mm:ss')
    status = True
    if switch == 'off':
        status = False
    if status:
        TriggerService.objects.filter(user=request.user).update(status=status, date_triggered=now)
    else:
        TriggerService.objects.filter(user=request.user).update(status=status)

    return HttpResponseRedirect(reverse('base'))
158477
function turnOff(device) {
    return api.request('/device/turnOff?' + querystring.stringify({id: device.id || device}));
  }
938579
def switch_on(self):
        """"""
        success = self.set_status(CONST.STATUS_OPEN_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_OPEN

        return success
980628
def do_mode(self, arg):
        
        restart_server = False
        if self.server.is_server_running() == 'yes' or self.server.is_server_running() == 'maybe':
            r = raw_input("Switching modes requires the server to restart. Really "
                          "switch modes? y or n: ")
            if r != 'y':
                return
            restart_server = True
        if arg['<which>'] is None:
            if self.sandbox:
                arg['<which>'] = 'live'
            else:
                arg['<which>'] = 'sandbox'
        if arg['<which>'] == 'live':
            self.set_sandbox(False)
            self.update_hit_tally()
            print 'Entered %s mode' % colorize('live', 'bold')
        else:
            self.set_sandbox(True)
            self.update_hit_tally()
            print 'Entered %s mode' % colorize('sandbox', 'bold')
        if restart_server:
            self.server_restart()
400033
public boolean isWebSocketClosing(HttpRequest request) {
        Channel channel = getWebSocketChannel(request);
        if (channel != null && channel.getParent() != null) {
            WebSocketCompositeChannel parent = (WebSocketCompositeChannel)channel.getParent();
            if (parent != null) {
                return parent.getReadyState() == ReadyState.CLOSED || parent.getReadyState() == ReadyState.CLOSING;
            }
        }
        return false;
    }
1094264
public boolean requestShouldBeHandledByTAI(HttpServletRequest request, MicroProfileJwtTaiRequest mpJwtTaiRequest, boolean defaultConfig) {
        String methodName = "requestShouldBeHandledByTAI";
        if (tc.isDebugEnabled()) {
            Tr.entry(tc, methodName, request, mpJwtTaiRequest);
        }

        mpJwtTaiRequest = setTaiRequestConfigInfo(request, mpJwtTaiRequest, defaultConfig);
        boolean result = false;
        boolean ignoreAppAuthMethod = true;

        MicroProfileJwtConfig mpJwtConfig = null;
        try {
            mpJwtConfig = mpJwtTaiRequest.getOnlyMatchingConfig();
        } catch (MpJwtProcessingException e) {

        }
        if (mpJwtConfig != null) {
            if (shouldDeferToJwtSso(request, mpJwtConfig, mpJwtTaiRequest.getJwtSsoConfig())) {
                return false;
            }
            ignoreAppAuthMethod = mpJwtConfig.ignoreApplicationAuthMethod(); // true by default
            if (ignoreAppAuthMethod) {
                result = mpJwtTaiRequest.hasServices();
            } else {
                result = isMpJwtSpecifiedInLoginConfig(request);
            }
        }

        if (tc.isDebugEnabled()) {
            Tr.exit(tc, methodName, result);
        }
        return result;
    }
494261
@Override
  public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry)
      throws IOException {
    if (!supportsRetry) {
      return false;
    }
    // check if back-off is required for this response
    if (backOffRequired.isRequired(response)) {
      try {
        return BackOffUtils.next(sleeper, backOff);
      } catch (InterruptedException exception) {
        // ignore
      }
    }
    return false;
  }
766607
protected boolean isRestRequest(HttpServletRequest request) {
		return RestRequestMatcher.INSTANCE.matches(request) || AjaxRequestMatcher.INSTANCE.matches(request);
	}
728819
private CompletionStage<AggregatedHttpMessage> updateHealthStatus(
            ServiceRequestContext ctx, HttpRequest req) {
        return mode(ctx, req).thenApply(mode -> {
            if (!mode.isPresent()) {
                return BAD_REQUEST_RES;
            }

            final boolean isHealthy = mode.get();

            serverHealth.setHealthy(isHealthy);

            return isHealthy ? TURN_ON_RES : TURN_OFF_RES;
        });
    }
897137
public static synchronized boolean stop(final Context context, boolean forceStop) {
        if (forceStop) {
            return context.stopService(new Intent(context, UploadService.class));
        }
        return uploadTasksMap.isEmpty() && context.stopService(new Intent(context, UploadService.class));
    }
358620
private static void validateForCurrentMode(HttpMessage request) throws ApiException {
		if (!isValidForCurrentMode(request.getRequestHeader().getURI())) {
			throw new ApiException(ApiException.Type.MODE_VIOLATION);
		}
	}