forked from telefonicaid/fiware-orion
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1489 from FIWARE/forwarding/loop
Implemented support for the Via HTTP header
- Loading branch information
Showing
37 changed files
with
734 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* | ||
* Copyright 2023 FIWARE Foundation e.V. | ||
* | ||
* This file is part of Orion-LD Context Broker. | ||
* | ||
* Orion-LD Context Broker is free software: you can redistribute it and/or | ||
* modify it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* Orion-LD Context Broker is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. | ||
* | ||
* For those usages not covered by this license please contact with | ||
* orionld at fiware dot org | ||
* | ||
* Author: Ken Zangelin | ||
*/ | ||
#include <stdio.h> // snprintf | ||
#include <string.h> // strlen | ||
|
||
extern "C" | ||
{ | ||
#include "kalloc/kaAlloc.h" // kaAlloc | ||
} | ||
|
||
#include "logMsg/logMsg.h" // LM_* | ||
|
||
#include "orionld/common/orionldState.h" // orionldState | ||
#include "orionld/forwarding/viaCompose.h" // Own interface | ||
|
||
|
||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// viaCompose - | ||
// | ||
char* viaCompose(char* via, char* self) | ||
{ | ||
int viaLen = 6; // strlen("Via: ") + '\0' | ||
|
||
if (via != NULL) | ||
viaLen += strlen(via); | ||
viaLen += 6 + strlen(self); // 4: ", 1.1 " | ||
|
||
char* viaHeader = kaAlloc(&orionldState.kalloc, viaLen); | ||
|
||
if (viaHeader == NULL) | ||
LM_X(1, ("Out of memory (kaAlloc failed to allocate %d bytes", viaLen)); | ||
|
||
if (via != NULL) | ||
snprintf(viaHeader, viaLen, "Via: %s, 1.1 %s", via, self); // Hardcoding HTTP version 1.1 ... | ||
else | ||
snprintf(viaHeader, viaLen, "Via: 1.1 %s", self); | ||
|
||
LM_T(LmtHeaders, ("via: '%s'", viaHeader)); | ||
return viaHeader; | ||
} |
Oops, something went wrong.