Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed duplication of request header holding the unique request id. #495

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,32 @@ mvn install -PnonUiIntegrationTests
## Headers
This is a list of the custom headers used by Gateleen.

| Header | Description | Link to documentation |
|:-------------------- | :--------------------------------------- | :---------------------:|
| x-rp-unique-id | unique id | |
| x-request-id | id of the request (unique?) | |
| x-self-request | indicates if the request is triggered by a communication server and the target is the communication server itself | |
| x-rp-grp | group header | [gateleen-user](gateleen-user/README_user.md) |
| x-roles | role header | |
| x-delta | used by the delta parameter to mark a delta request | [gateleen-delta](gateleen-delta/README_delta.md) |
| x-delta-backend | used by the delta parameter as a marker header to know that we should let the request continue to the router | [gateleen-delta](gateleen-delta/README_delta.md) |
| x-expire-After | indicates how long (in seconds) a request is 'valid' before it expires | |
| x-hooked | used by the HookHandler to indicate the original hook request as hooked | [gateleen-hook](gateleen-hook/README_hook.md) |
| x-pack-size | indicates if a request is packed | [gateleen-packing](gateleen-packing/README_packing.md) |
| x-client-timestamp | timestamp of the client while sending the request | |
| x-server-timestamp | timestamp of the server while sending the request | |
| x-queue | indicates a queued request | [gateleen-queue](gateleen-queue/README_queue.md) |
| x-duplicate-check | indicates if a request is a duplicate or not | |
| Header | Description | Link to documentation |
|:---------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| :---------------------:|
| x-rp-unique_id | unique id of the request. Normally provided by a proxy server | |
| x-request-id | unique id of the request when no x-rp-unique_id request header was provided | |
| x-self-request | indicates if the request is triggered by a communication server and the target is the communication server itself | |
| x-rp-grp | group header | [gateleen-user](gateleen-user/README_user.md) |
| x-roles | role header | |
| x-delta | used by the delta parameter to mark a delta request | [gateleen-delta](gateleen-delta/README_delta.md) |
| x-delta-backend | used by the delta parameter as a marker header to know that we should let the request continue to the router | [gateleen-delta](gateleen-delta/README_delta.md) |
| x-expire-After | indicates how long (in seconds) a request is 'valid' before it expires | |
| x-hooked | used by the HookHandler to indicate the original hook request as hooked | [gateleen-hook](gateleen-hook/README_hook.md) |
| x-pack-size | indicates if a request is packed | [gateleen-packing](gateleen-packing/README_packing.md) |
| x-client-timestamp | timestamp of the client while sending the request | |
| x-server-timestamp | timestamp of the server while sending the request | |
| x-queue | indicates a queued request | [gateleen-queue](gateleen-queue/README_queue.md) |
| x-duplicate-check | indicates if a request is a duplicate or not | |
| x-on-behalf-of | indicates the user the request originally was made from. This header is used when the request of a user is sent by another user because it couldn't be sent at that time (offline) | |
| x-user-\<pattern\> | used for the user profile | |
| x-rp-deviceid | used to check if device is authorized | |
| x-rp-usr | used to check if user is authorized | [gateleen-user](gateleen-user/README_user.md) |
| x-rp-lang | used to specify the language of the user profile | [gateleen-user](gateleen-user/README_user.md) |
| x-valid | indicates if a request is to be validated or not | [gateleen-validation](gateleen-validation/README_validation.md) |
| x-sync | | |
| x-log | | |
| x-service | contains the name of the service, which created the request | |
| x-queue-expire-after | indicates how long (in seconds) a request is 'valid' in the queue before it expires | |
| x-user-\<pattern\> | used for the user profile | |
| x-rp-deviceid | used to check if device is authorized | |
| x-rp-usr | used to check if user is authorized | [gateleen-user](gateleen-user/README_user.md) |
| x-rp-lang | used to specify the language of the user profile | [gateleen-user](gateleen-user/README_user.md) |
| x-valid | indicates if a request is to be validated or not | [gateleen-validation](gateleen-validation/README_validation.md) |
| x-sync | | |
| x-log | | |
| x-service | contains the name of the service, which created the request | |
| x-queue-expire-after | indicates how long (in seconds) a request is 'valid' in the queue before it expires | |

## Performance Tuning
* The amount of max open files per process should be at least 16384. You can check your max open files per process with this command `cat /proc/<process id>/limits`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public static Logger getLogger(Class<?> clazz, MultiMap headers) {
uid = rid;
}
rid = headers.get("x-rp-unique_id");
if (rid == null) {
rid = headers.get("x-rp-unique-id");
}
if (rid != null) {
if (uid != null) {
uid = uid + " " + rid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testLogRequest(TestContext context){
EventBus eventBus = Mockito.mock(EventBus .class);
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
headers.add("Content-Type", "application/json");
headers.add("x-rp-unique-id", "123456");
headers.add("x-rp-unique_id", "123456");
MockedResponse response = new MockedResponse(MultiMap.caseInsensitiveMultiMap());
MockedRequest request = new MockedRequest("/uri/to/a/resource", HttpMethod.PUT, headers, response);
JsonObject body = new JsonObject().put("key_1", "value_2").put("key_2", 99);
Expand All @@ -47,7 +47,7 @@ public void testLogRequest(TestContext context){
JsonObject expected = new JsonObject();
expected.put(REQUEST_URI, "/uri/to/a/resource");
expected.put(REQUEST_METHOD, "PUT");
JsonObject requestHeaders = new JsonObject().put("Content-Type", "application/json").put("x-rp-unique-id", "123456");
JsonObject requestHeaders = new JsonObject().put("Content-Type", "application/json").put("x-rp-unique_id", "123456");
expected.put(REQUEST_HEADERS, requestHeaders);
expected.put(RESPONSE_HEADERS, new JsonObject());
expected.put(REQUEST_STATUS, StatusCode.OK.getStatusCode());
Expand All @@ -62,7 +62,7 @@ public void testLogRequestResponseHeaders(TestContext context){
EventBus eventBus = Mockito.mock(EventBus .class);
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
headers.add("Content-Type", "application/json");
headers.add("x-rp-unique-id", "123456");
headers.add("x-rp-unique_id", "123456");
MockedRequest request = new MockedRequest("/uri/to/a/resource", HttpMethod.PUT, headers,
new MockedResponse(MultiMap.caseInsensitiveMultiMap()));
JsonObject body = new JsonObject().put("key_1", "value_2").put("key_2", 99);
Expand All @@ -76,7 +76,7 @@ public void testLogRequestResponseHeaders(TestContext context){
JsonObject expected = new JsonObject();
expected.put(REQUEST_URI, "/uri/to/a/resource");
expected.put(REQUEST_METHOD, "PUT");
JsonObject requestHeaders = new JsonObject().put("Content-Type", "application/json").put("x-rp-unique-id", "123456");
JsonObject requestHeaders = new JsonObject().put("Content-Type", "application/json").put("x-rp-unique_id", "123456");
expected.put(REQUEST_HEADERS, requestHeaders);
JsonObject responseHeadersJsonObject = new JsonObject().put("header_1", "value_1").put("header_2", "value_2");
expected.put(RESPONSE_HEADERS, responseHeadersJsonObject);
Expand Down
2 changes: 1 addition & 1 deletion gateleen-logging/README_logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,5 @@ Examples of logged request payloads and headers:
```json
{"url":"/gateleen/server/test/r1","method":"GET","statusCode":304,"statusMessage":"Not Modified","request":{"headers":{"x-server-timestamp":"2015-01-21T15:12:21.392+01:00"}},"response":{"headers":{}}}
{"url":"/gateleen/server/test/r1","method":"GET","statusCode":304,"statusMessage":"Not Modified","request":{"headers":{"if-none-match":"adafffea-cc94-4cf0-b138-9420f9c4fa27"}},"response":{"headers":{}}}
{"url":"/gateleen/server/test/r1","method":"GET","statusCode":304,"statusMessage":"Not Modified","request":{"headers":{"connection":"keep-alive","cache-control":"max-age=0","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","user-agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36","accept-encoding":"gzip, deflate, sdch","accept-language":"de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4,fr;q=0.2,it;q=0.2","cookie":"JSESSIONID=ljv80nz7bmfz1wynkwpf5lte5","if-none-match":"adafffea-cc94-4cf0-b138-9420f9c4fa27","x-rp-unique_id":"5edb1d7c7ee93b3dd65779d39171c02c","x-server-timestamp":"2015-01-21T13:49:47.172+01:00","x-rp-unique-id":"5edb1d7c7ee93b3dd65779d39171c02c","host":"localhost:8989","transfer-encoding":"chunked"}},"response":{"headers":{"etag":"adafffea-cc94-4cf0-b138-9420f9c4fa27","content-length":"0"}}}
{"url":"/gateleen/server/test/r1","method":"GET","statusCode":304,"statusMessage":"Not Modified","request":{"headers":{"connection":"keep-alive","cache-control":"max-age=0","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","user-agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36","accept-encoding":"gzip, deflate, sdch","accept-language":"de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4,fr;q=0.2,it;q=0.2","cookie":"JSESSIONID=ljv80nz7bmfz1wynkwpf5lte5","if-none-match":"adafffea-cc94-4cf0-b138-9420f9c4fa27","x-rp-unique_id":"5edb1d7c7ee93b3dd65779d39171c02c","x-server-timestamp":"2015-01-21T13:49:47.172+01:00","host":"localhost:8989","transfer-encoding":"chunked"}},"response":{"headers":{"etag":"adafffea-cc94-4cf0-b138-9420f9c4fa27","content-length":"0"}}}
```
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,6 @@ private PatternAndCircuitHash getPatternAndCircuitHashFromRequest(HttpRequest re

private String getRequestUniqueId(HttpRequest request) {
String unique = request.getHeaders().get("x-rp-unique_id");
if (unique == null) {
unique = request.getHeaders().get("x-rp-unique-id");
}
if (unique == null) {
log.warn("request to {} has no unique-id header. Using request uri instead", request.getUri());
unique = request.getUri();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@ public void handle(AsyncResult<HttpClientRequest> event) {
cReq.headers().set(SELF_REQUEST_HEADER, "true");
}

if (uniqueId != null) {
cReq.headers().set("x-rp-unique-id", uniqueId);
}
setProfileHeaders(log, profileHeaderMap, cReq);

if (base64UsernamePassword != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public void handle(final RoutingContext ctx) {
return;
}

setUniqueIdHeader(requestHeaders);

final Buffer header = Buffer.buffer(new HttpRequest(ctx.request().method(), targetUri, requestHeaders, null).toJsonObject().encode());
final Buffer requestBuffer = Buffer.buffer();
requestBuffer.setInt(0, header.length()).appendBuffer(header);
Expand All @@ -105,9 +103,6 @@ public void handle(final RoutingContext ctx) {
MultiMap responseHeaders = null;
if (headers != null && headers.size() > 0) {
responseHeaders = JsonMultiMap.fromJson(headers);

setUniqueIdHeader(responseHeaders);

ctx.response().headers().setAll(responseHeaders);
}
corsHandler.handle(ctx.request());
Expand Down Expand Up @@ -151,16 +146,4 @@ public void handle(final RoutingContext ctx) {

}));
}

/**
* Translates the x-rp-unique_id header to x-rp-unique-id.
*
* @param headers the request headers
*/
private void setUniqueIdHeader(MultiMap headers) {
final String uid = headers.get("x-rp-unique_id");
if (uid != null) {
headers.set("x-rp-unique-id", uid);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,6 @@ private void logRequest(HttpServerRequest request) {
if (uid != null) {
sb.append(uid);
sb.append(" ");
} else {
uid = request.headers().get("x-rp-unique-id");
if (uid != null) {
sb.append(uid);
sb.append(" ");
}
}

sb.append(request.method());
Expand Down