I need to know the exact use of NO_ENTITY_BODY.Explanation with example could be more useful.
For GET and DELETE API calls, this property is set in the message context by default. This is used for internal purposes.
In case you want to send a response from ESB to such a request, you need to remove this property. Otherwise, the response body of the message is also ignored and an empty response is sent back to the client.
Related
I am new to firebase and I came to know that the headers cannot be accessed inside an https.onCall function,only option is to use https.onRequest only. May I know if there is any workaround to access headers inside a https.onCall method please.
There is no workaround - the API does not allow it. Callable functions take full control over headers on both the client and server according to the specification, and you must accept that if you want to use callable functions.
If you need access to a headers, you should not use callables at all and use normal HTTP functions instead, where you have full control.
Depending on what your use case is, if you must use callable functions, you can instead use the payload of the request to transmit data to your function.
For the time being, the rawRequest is available on the CallableContext.
So, you can set a response header with a line like the following:
context.rawRequest.res?.header('X-My-Header', 'CustomValue')
https://firebase.google.com/docs/reference/functions/common_providers_https.callablecontext
My project uses ApplicationInsightsHttpModule which initializes Operation.Id from Microsoft.ApplicationInsights.RequestTelemetry HTTP value set by a client UI application. Now I want my API to be consumed by a third party which will provide X-Operation-Id HTTP header to correlate our activities. How do I make Application Insights to initialize Operation.Id from that header if it's present in a request?
This says that the standard context is managed automatically by AI so I need a code sample that shows how to properly initialize Operation.Id with a custom value. The following code isn't working, the header value is ignored:
var operationInitializer = TelemetryConfiguration.Active.TelemetryInitializers.OfType<Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer>().FirstOrDefault();
if (operationInitializer != null)
{
operationInitializer.RootOperationIdHeaderName = "X-Operation-Id";
}
The code that you included in your question should be working at first glance: you are looking for correct initializer and overriding correct property. However there could be multiple reasons why it is not working as expected, and debugging this is hard, because it would require you to actually step into Application Insights code (if you do decide, the sources for every release are archived on GH).
My recommendation in your case would be to take a different approach - instead of trying to override this property, create and register your own telemetry initializer to set Operation.ID from your header. If you set this property, OperationCorrelationTelemetryInitializer will ignore it and not override. This way you confirm that your headers can be read correctly, and you can easily set breakpoint in Initialize method to debug.
At the moment the question was asked AI SDK had version 2.2. Recently I've upgraded to the latest version 2.4 and it's working now as intended. So, if you pass say 'HELLO' in X-Operation-Id HTTP header (you still need that code in the question in Application_Start()) and then ask for a telemetry in Application_BeginRequest() (or wherever HttpContext is available):
RequestTelemetry telemetry = HttpContext.Current.GetRequestTelemetry();
telemetry.Id will contain something like |HELLO.d0b9d5b7_.
That hexadecimal suffix increases if you pass 'HELLO' in the next request so Id is always unique. I don't know if that can be overridden though.
I'm working on an servlet based project where I found that in a place, a value is set using request.setAttribute("") and in another place, that value is retrieved using request.getParameter(""). Is this right?
I know the difference between the getParameter and getAttribute. But the retrieved value intermittently becomes null.
Only those values can be retrieved using request.getAttribute which are set using request.setAttribute. And query string in GET request or request prameters in POST request can be retrieved using request.getParameter. There is no method as request.setParameter in Servlet API. Now coming to the intermittent behavior, check the URL/AJAX request on each request to server and see exactly when it has the property and its value set which you are trying to retrieve using getParameter method. Hope this clarify your issue.
I have following ajax call
open: function () {
$(this).load("MyBox.aspx?sec=L&levId=" + RowId);
}
so people can see the querystring, so the user can copy url and paste it to browser but how can i block that? I dont want it to shown from browser. How I can do that? I m using asp.net and jquery.
load function issues a GET request. Instead of that, you may use a jQuery POST call and get the data. Users can't get the result by pasting it in browser and hit enter (which is GET request)
var thatObject=$(this);
$.post("MyBox.aspx?sec=L&levId=" + RowId,function(response){
thatObject.html(response);
})
In the server page, you can read the values posted by checking the Request.Form collection (instead of Request.QueryString).
from msdn
The Form collection retrieves the values of form elements posted to
the HTTP request body, with a form using the POST method.
You can determine whether the call is a GET call or POST call by inspecting the Request.RequestType property value. This way you can avoid people issuing GET request to this method and getting the response.
But remember that, there are tools/browser addons which does the POST request from browser.
Also if the data is for authorized users, you may check the user is authorized to access it in the server page(MYbox.aspx) before returning the content.
You can't. You can never trust any code running on the client. If you need to hide data on the client, you should create a server based session and then put a session token in an encrypted cookie.
From wikipedia and W3C
Some methods (for example, HEAD, GET, OPTIONS and TRACE) are defined as safe, which means they are intended only for information retrieval and should not change the state of the server. In other words, they should not have side effects, beyond relatively harmless effects such as logging, caching, the serving of banner advertisements or incrementing a web counter.
Making arbitrary GET requests without regard to the context of the application's state should therefore be considered safe.
By contrast, methods such as POST, PUT and DELETE are intended for actions that may cause side effect
If your get request changes the state of the server (which it most likely does based on your post), you are doing something wrong. What you're trying to do is impossible. You need to rethink your architecture.
I'm using the WCFMock to mock the WebOperationContext in my web service. The only usage is to add a custom HTTP header to the WebOperationContext.Current.OutgoingResponse.Headers collection. I'm unable to verify this using Moq. What I've already tried:
Verify if the Add method is getting invoked. This fails because Add is not virtual
Try to access the header directly from MockedWebOperationContext.Current. This is always zero in number
How can I verify in my unit test case that a custom header has been added?
Figured it out. Here's the solution for posterity.
When we create the "moq mock" for the IWebOperationContext, the example suggests that we set the property DefaultValue = DefaultValue.Mock. This will mock all dependincies including the HttpHeaders collection. I skipped this and mocked the OutgoingWebResponseContext to return a WebHeaderCollection. For my test case I simply assert on this collection.