Skip to content

Commit

Permalink
Merge pull request #1533 from FIWARE/bug/1532-Host-header-in-notifica…
Browse files Browse the repository at this point in the history
…tions

Fixed issue #1532
  • Loading branch information
kzangeli authored Jan 12, 2024
2 parents 5165cf1 + 252ee72 commit 0c94e08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/lib/orionld/notifications/notificationSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,10 @@ int notificationSend(OrionldAlterationMatch* mAltP, double timestamp, CURL** cur
if (headers > 50)
LM_X(1, ("Too many HTTP headers (>50) for a Notification - to support that many, the broker needs a SW update and to be recompiled"));

char hostHeader[256];
char hostHeader[512];
size_t hostHeaderLen;

hostHeaderLen = snprintf(hostHeader, sizeof(hostHeader), "Host: %s\r\n", mAltP->subP->ip);
hostHeaderLen = snprintf(hostHeader, sizeof(hostHeader), "Host: %s:%d\r\n", mAltP->subP->ip, mAltP->subP->port);

int ioVecLen = headers + 3; // Request line + X headers + empty line + payload body
int headerIx = 7;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/orionld/pernot/pernotSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ bool pernotSend(PernotSubscription* subP, KjNode* entityArray)
//
headers += subP->headers.items;

char hostHeader[128];
size_t hostHeaderLen = snprintf(hostHeader, sizeof(hostHeader) - 1, "Host: %s\r\n", subP->ip);
char hostHeader[512];
size_t hostHeaderLen = snprintf(hostHeader, sizeof(hostHeader) - 1, "Host: %s:%d\r\n", subP->ip, subP->port);

int ioVecLen = headers + 3; // Request line + X headers + empty line + payload body
struct iovec ioVec[53] = {
Expand Down
8 changes: 4 additions & 4 deletions test/functionalTest/cases/0000_ngsild/ngsild_issue_1495.test
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ Date: REGEX(.*)

03. Dump/Reset the accumulator, see the entity
==============================================
POST https://127.0.0.1/notify
POST https://127.0.0.1:REGEX(\d+)/notify
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LCJtYW5hZ2UtcmVhbG0iLCJ2aWV3LWV2ZW50cyIsInZpZXctdXNlcnMiLCJ2aWV3LWNsaWVudHMiLCJtYW5hZ2UtYXV0aG9yaXphdGlvbiIsIm1hbmFnZS1jbGllbnRzIiwicXVlcnktZ3JvdXBzIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6InByb2ZpbGUgZW1haWwiLCJzaWQiOiJjZGU5OTk0Ni01MDNlLTQ2NjktODQ1Ni03ZTI4YTg0NjM3YTkiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInByZWZlcnJlZF91c2VybmFtZSI6ImFlcm9zX3VzZXJfMiIsImdpdmVuX25hbWUiOiIiLCJmYW1pbHlfbmFtZSI6IiJ9.VDnNuP497t7SjYlXzCWaWUw33e3OPwLpB0xqCsOgekgwBySuaUpqJ6xaCssrmdgx8WYg3EE76GdcvnKSkC1oeTiR49AeKXK3D-UE8uj60zZKwXwQVapP7LhowraQpGeiwirGDZc9DV5at8pMR2gH3c88KSVtudxJQUcwm7wt0qvlX0M1eDJOo4YYjs41mIQiBWmIxantt3qXapk7ZzyByp3sp2Kzo6wJVAcJRlkoIsXBxAh6n5D1gerJzwh0f5OZMpxgjwCF3Jjps4Wjkh0je-CHFF-x0cSIS_LsqbPgys--mmuxyeXUF4W1wI2WyW36glEkCDdnZpbGhQXqtpFlxg
User-Agent: orionld/REGEX(.*)
Host: 127.0.0.1
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: application/json
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand Down Expand Up @@ -282,10 +282,10 @@ Date: REGEX(.*)

05. Dump/Reset the accumulator, see the modified entity
=======================================================
POST https://127.0.0.1/notify
POST https://127.0.0.1:REGEX(\d+)/notify
Content-Length: 590
User-Agent: orionld/REGEX(.*)
Host: 127.0.0.1
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: application/json
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
Expand Down

0 comments on commit 0c94e08

Please sign in to comment.