Log original incoming request

@param requestType
@param request
@param history
180949
private void logOriginalRequestHistory(String requestType,
                                           HttpServletRequest request, History history) {
        logger.info("Storing original request history");
        history.setRequestType(requestType);
        history.setOriginalRequestHeaders(HttpUtilities.getHeaders(request));
        history.setOriginalRequestURL(request.getRequestURL().toString());
        history.setOriginalRequestParams(request.getQueryString() == null ? "" : request.getQueryString());
        logger.info("Done storing");
    }
1183596
def log(**data):
	
	# Get data from request body
	entry = {
		"module": data["params"]["module"],
		"event": data["params"]["event"],
		"timestamp": data["params"]["timestamp"],
		"arguments": data["params"]["arguments"]
	}
	# Call create metod for writing data to database
	history.create(entry)
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);
      }
    }
  }
580843
private void addQueryParams(final Request request) {
        if (bindingType != null) {
            for (Binding.BindingType prop : bindingType) {
                request.addQueryParam("BindingType", prop.toString());
            }
        }

        if (identity != null) {
            for (String prop : identity) {
                request.addQueryParam("Identity", prop);
            }
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
768661
function logRequest(req, res) {
		var responseTime = Math.round(req.duration),
			shouldLogRequest = requestLogger && req && req.url && req.url !== '/arrowPing.json',
			shouldADILog = options && options.adiLogging && adiLogger && req && req.url && isWhitelisted(req.url),
			time = new Date().getTime(),
			uri = (req.route && req.route.path) || req.path || (req.url && req.url.split('?')[0]),
			localPort = getPort(req);

		if (shouldLogRequest && req.log && req.logname && (req.logmetadata === undefined || req.logmetadata)) {
			requestLogger.info({
				req_id: req.requestId,
				req: req,
				res: res,
				route: req.route,
				name: req._logname,
				logname: req.logname,
				response_time: responseTime
			});

			const result = {
				url: req.url,
				req_headers: req.headers,
				status: res.status,
				req_id: req.requestId,
				name: req._logname,
				logname: req.logname,
				response_time: responseTime
			};
			fs.writeFile(req.logname + '.metadata', JSON.stringify(result));
		} else if (shouldLogRequest) {
			requestLogger.info({
				req_id: req.requestId,
				response_time: responseTime,
				route: req.route,
				req: req,
				res: res
			});
		}

		if (shouldADILog) {
			adiLogger.info({
				type: 'transaction',
				time: time,
				path: uri,
				protocol: req.protocol,
				protocolSrc: localPort,
				duration: responseTime,
				status: getStatus(res),
				serviceContexts: [
					{
						service: '',
						monitor: '',
						client: null,
						org: null,
						app: options.name,
						method: '',
						status: '',
						duration: ''
					}
				],
				customMsgAtts: {},
				correlationId: getCorrelationId(req),
				legs: [
					{
						uri: uri,
						status: res.statusCode,
						statusText: '',
						method: req.method,
						vhost: null,
						wafStatus: 0,
						bytesSent: parseInt(res.get('Content-Length'), 10) || null,
						bytesReceived: parseInt(req.get('Content-Length'), 10) || null,
						remoteName: '',
						remoteAddr: '',
						localAddr: '',
						remotePort: '',
						localPort: '',
						sslsubject: null,
						leg: 0,
						timestamp: time,
						duration: responseTime,
						serviceName: uri,
						subject: null,
						operation: req.method + ' - ' + uri,
						type: req.protocol,
						finalStatus: ''
					}
				]
			});
		}
		if (req.cleanStream) {
			req.cleanStream();
			req.cleanStream = null;
		}
	}
707256
private static boolean isHistoryTypeToShow(int historyType) {
        return historyType == HistoryReference.TYPE_PROXIED || historyType == HistoryReference.TYPE_ZAP_USER
                || historyType == HistoryReference.TYPE_AUTHENTICATION || historyType == HistoryReference.TYPE_PROXY_CONNECT;
    }
1212741
private void addQueryParams(final Request request) {
        if (dateCreatedFrom != null) {
            request.addQueryParam("DateCreatedFrom", dateCreatedFrom.toString());
        }

        if (dateCreatedTo != null) {
            request.addQueryParam("DateCreatedTo", dateCreatedTo.toString());
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
631381
@Override
  public void recordTaskClaim(TaskEntity task) {
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
      HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskInstanceEntityManager().findById(task.getId());
      if (historicTaskInstance != null) {
        historicTaskInstance.setClaimTime(task.getClaimTime());
      }
    }
  }
999736
public static void logLoadedServices(Logger log, Class<?> type, List<?> services)
    {
        log.info("Loaded [" + services.size() + "] " + type.getName() + " [" + NEWLINE
                    + joinTypeNames(new ArrayList<>(services)) + "]");
    }
1241703
private void addQueryParams(final Request request) {
        if (recurring != null) {
            request.addQueryParam("Recurring", recurring.toString());
        }

        if (triggerBy != null) {
            request.addQueryParam("TriggerBy", triggerBy.toString());
        }

        if (usageCategory != null) {
            request.addQueryParam("UsageCategory", usageCategory.toString());
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
1159104
def log_request(_, request, *_args, **_kwargs):
    # type: (Any, ClientRequest, str, str) -> None
    
    if not _LOGGER.isEnabledFor(logging.DEBUG):
        return

    try:
        _LOGGER.debug("Request URL: %r", request.url)
        _LOGGER.debug("Request method: %r", request.method)
        _LOGGER.debug("Request headers:")
        for header, value in request.headers.items():
            if header.lower() == 'authorization':
                value = '*****'
            _LOGGER.debug("    %r: %r", header, value)
        _LOGGER.debug("Request body:")

        # We don't want to log the binary data of a file upload.
        if isinstance(request.body, types.GeneratorType):
            _LOGGER.debug("File upload")
        else:
            _LOGGER.debug(str(request.body))
    except Exception as err:  # pylint: disable=broad-except
        _LOGGER.debug("Failed to log request: %r", err)
424534
public static DeleteRequest checkRequest(final HttpServletRequest request,
			final DeleteResponse deleteResponse) {
		final DeleteRequestType type = checkType(request, deleteResponse);
		if (type != null) {
			return new DeleteRequest(type);
		}

		return null;
	}
1098526
private void processClientId(HttpServletRequest httpServletRequest, History history) {
        // get the client id from the request header if applicable.. otherwise set to default
        // also set the client uuid in the history object
        if (httpServletRequest.getHeader(Constants.PROFILE_CLIENT_HEADER_NAME) != null &&
            !httpServletRequest.getHeader(Constants.PROFILE_CLIENT_HEADER_NAME).equals("")) {
            history.setClientUUID(httpServletRequest.getHeader(Constants.PROFILE_CLIENT_HEADER_NAME));
        } else {
            history.setClientUUID(Constants.PROFILE_CLIENT_DEFAULT_ID);
        }
        logger.info("Client UUID is: {}", history.getClientUUID());
    }
957146
public void setRequestType(int pathId, Integer requestType) {
        if (requestType == null) {
            requestType = Constants.REQUEST_TYPE_GET;
        }
        PreparedStatement statement = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement(
                "UPDATE " + Constants.DB_TABLE_PATH +
                    " SET " + Constants.PATH_PROFILE_REQUEST_TYPE + " = ?" +
                    " WHERE " + Constants.GENERIC_ID + " = ?"
            );
            statement.setInt(1, requestType);
            statement.setInt(2, pathId);
            statement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
1088323
public void addHistory(History history) {
        if (disableHistoryWrite) {
            return;
        }
        PreparedStatement statement = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement("INSERT INTO " + Constants.DB_TABLE_HISTORY +
                                                           "(" + Constants.GENERIC_PROFILE_ID + "," + Constants.GENERIC_CLIENT_UUID + "," +
                                                           Constants.HISTORY_CREATED_AT + "," + Constants.GENERIC_REQUEST_TYPE + "," +
                                                           Constants.HISTORY_REQUEST_URL + "," + Constants.HISTORY_REQUEST_PARAMS + "," +
                                                           Constants.HISTORY_REQUEST_POST_DATA + "," + Constants.HISTORY_REQUEST_HEADERS + "," +
                                                           Constants.HISTORY_RESPONSE_CODE + "," + Constants.HISTORY_RESPONSE_HEADERS + "," +
                                                           Constants.HISTORY_RESPONSE_CONTENT_TYPE + "," + Constants.HISTORY_RESPONSE_DATA + "," +
                                                           Constants.HISTORY_ORIGINAL_REQUEST_URL + "," + Constants.HISTORY_ORIGINAL_REQUEST_PARAMS + "," +
                                                           Constants.HISTORY_ORIGINAL_REQUEST_POST_DATA + "," + Constants.HISTORY_ORIGINAL_REQUEST_HEADERS + "," +
                                                           Constants.HISTORY_ORIGINAL_RESPONSE_CODE + "," + Constants.HISTORY_ORIGINAL_RESPONSE_HEADERS + "," +
                                                           Constants.HISTORY_ORIGINAL_RESPONSE_CONTENT_TYPE + "," + Constants.HISTORY_ORIGINAL_RESPONSE_DATA + "," +
                                                           Constants.HISTORY_MODIFIED + "," + Constants.HISTORY_REQUEST_SENT + "," +
                                                           Constants.HISTORY_REQUEST_BODY_DECODED + "," + Constants.HISTORY_RESPONSE_BODY_DECODED + "," +
                                                           Constants.HISTORY_EXTRA_INFO + "," + Constants.HISTORY_RAW_POST_DATA + ")" +
                                                           " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
            statement.setInt(1, history.getProfileId());
            statement.setString(2, history.getClientUUID());
            statement.setString(3, history.getCreatedAt());
            statement.setString(4, history.getRequestType());
            statement.setString(5, history.getRequestURL());
            statement.setString(6, history.getRequestParams());
            statement.setString(7, history.getRequestPostData());
            statement.setString(8, history.getRequestHeaders());
            statement.setString(9, history.getResponseCode());
            statement.setString(10, history.getResponseHeaders());
            statement.setString(11, history.getResponseContentType());
            statement.setString(12, history.getResponseData());
            statement.setString(13, history.getOriginalRequestURL());
            statement.setString(14, history.getOriginalRequestParams());
            statement.setString(15, history.getOriginalRequestPostData());
            statement.setString(16, history.getOriginalRequestHeaders());
            statement.setString(17, history.getOriginalResponseCode());
            statement.setString(18, history.getOriginalResponseHeaders());
            statement.setString(19, history.getOriginalResponseContentType());
            statement.setString(20, history.getOriginalResponseData());
            statement.setBoolean(21, history.isModified());
            statement.setBoolean(22, history.getRequestSent());
            statement.setBoolean(23, history.getRequestBodyDecoded());
            statement.setBoolean(24, history.getResponseBodyDecoded());
            statement.setString(25, history.getExtraInfoString());
            statement.setBytes(26, history.getRawPostData());
            statement.executeUpdate();

            // cull history
            cullHistory(history.getProfileId(), history.getClientUUID(), maxHistorySize);
        } catch (Exception e) {
            logger.info(e.getMessage());
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
188546
function logHttpRequestError (uniqueId, err) {
    // require log client
    if (!logClient) {
        return
    }
    // log error
    logClient.log('httpRequestError', {
        httpRequestId: uniqueId.id,
        httpRequestErrorCreateTime: microTimestamp(),
        httpRequestError: err.message,
    })
}
727699
private void initHistoryUpdaters() {
        historyUpdaters.put(RequestType.EXEC,
                            new HistoryUpdater<JmxExecRequest>() {
                                /** {@inheritDoc} */
                                public void updateHistory(JSONObject pJson,JmxExecRequest request, long pTimestamp) {
                                    HistoryEntry entry = historyStore.get(new HistoryKey(request));
                                    if (entry != null) {
                                        synchronized(entry) {
                                            pJson.put(KEY_HISTORY,entry.jsonifyValues());
                                            entry.add(pJson.get(KEY_VALUE),pTimestamp);
                                        }
                                    }
                                }
                            });
        historyUpdaters.put(RequestType.WRITE,
                            new HistoryUpdater<JmxWriteRequest>() {
                                /** {@inheritDoc} */
                                public void updateHistory(JSONObject pJson,JmxWriteRequest request, long pTimestamp) {
                                    HistoryEntry entry = historyStore.get(new HistoryKey(request));
                                    if (entry != null) {
                                        synchronized(entry) {
                                            pJson.put(KEY_HISTORY,entry.jsonifyValues());
                                            entry.add(request.getValue(),pTimestamp);
                                        }
                                    }
                                }
                            });
        historyUpdaters.put(RequestType.READ,
                            new HistoryUpdater<JmxReadRequest>() {
                                /** {@inheritDoc} */
                                public void updateHistory(JSONObject pJson,JmxReadRequest request, long pTimestamp) {
                                    updateReadHistory(request,pJson,pTimestamp);
                                }
                            });

    }