Connection state with libmicrohttpd and http 102 - c

What I am trying to achieved is:
Send http 102 to client who requested somedoc.html
Some processing on the side including out of band authentication
If authenticated, send response built from somedoc.html, otherwise generic not auth message
I'm having a failure of understanding somewhere, in that I cannot seem to figure out how to send the 102 and save the connection details so that I can forward the response in step 3. I had thought I could queue a response then either enter a wait loop or suspend the connection, but as far as I can tell I have to return from the MHD_AcceptPolicyCallback for the response to be sent, then I cannot figure out how to get back to the connection. I have looked at the request completed call back but this still results in the 102 not being sent.
I really can't figure out a process to achieve these steps from the examples or the manual and any help would be appreciated.

HTTP standards doesn't define response code 102.
See https://www.rfc-editor.org/rfc/rfc7231#section-6
and https://www.rfc-editor.org/rfc/rfc2616#section-6.1.1
HTTP protocol use request-response logic. If you already responded to some request then you can't add another response later to the same request.

After talking with the developer, the 102 status code was defined "for completeness"; however, no attempt has been made to implement the required functionality to actually be able to use this status code in a meaningful way on a server developed with the libmicrohttpd library.

Related

How to let users know flow has completed?

I have a flow setup in logicapps that starts with a http response, the user enters data in an excel sheet and clicks a cell/hyperlink which kicks things off. They receive a response saying the flow has started and was wondering how I could update the response once the flow has completed (either successfully or if it has failed). I’ve only created basic flows before and when googling I’m not too sure what I should be searching for but cant find any examples of what I’m trying to achieve, any ideas?
Here is one of the workarounds that might work. You need to add the response at the end of the flow. Consider my logic app as a sample. If my "Var" is yes then in response it sends Success as a response to my postman and if it is other than yes it sends Failed. Here is my logic app for your reference:-
Result:
In postman
In your case, you can use some properties to define if they got classes or not and then use the same condition connector to send the response.

HTTP:TIMEOUT error through mule request connector but api working through postman

I am using mule-4. I am trying to integrate a third-party API(confidential). It is working from the postman and is returning responses within 1 second.
When I wrote a request connector for the same in mule, The API kept giving a timeout exception.
I increased the response timeout to 2 minutes then also got the same error i.e. timeout exceeded.
Please help.
EDIT 1:
I was able to reproduce this issue on postman. SO postman is adding Connection:keep-alive header by default and when this particular header is added then the API gives response within seconds but when this header is missing then the API gives a timeout error.
You are not really providing too much details of the issue. I can give some generic guidelines:
Ensure that there is network connectivity. If you are testing Postman and Mule from the same computer it is probably not an issue.
Ensure host, port and certificates (if using TLS) are the same. Pointing an HTTPS request to port 80 could cause a timeout sometimes.
Enable HTTP Wire logging in Mule and compare with Postman code as HTTP to identify any significant difference between the requests. For example: headers, URI, body should be the same, except probably for a few headers. Depends on the API. This is usually the main cause for differences between Postman and Mule, when the request are different.

duplicate ajax calls in angularjs

I am using express-jwt to build a restful api. Now the client is making duplicate ajax calls, for the first one the initiator is angularjs and for the second one the initiator is other. The first one gets 204 as the response code and the second one gets 200 as the response code. I tried to debug to get to the source of this duplicate requests, but I am not able to.
Below is the header details for the one with 204 status code
Below is the header details for the one with 204 status code
Can any one suggest what could be the issue?
The first call is OPTIONS type. That's a pre-flight call which a browser sends if the page and api are not on same domain.
The purpose of this call is to deal with CORS. Backend usually needs to send the allowed request method types (GET, POST etc.). The browser will then send the real call if the desired request type is among those returned.
Here's a sample of the response headers.
You can ignore it for all intents and purposes. It does not contain any normally useful payload or return data.
Take a look at AJAX in Chrome sending OPTIONS instead of GET/POST/PUT/DELETE? for more info.
Those two requests are different one is OPTIONS and other is GET.
For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server.
You need to handle in the server when the request method OPTIONS , then you need to exit with out processing.

Stop Silverlight 5 from throwing WebExceptions for non-200 status codes?

I am trying to develop a client application that calls a RESTful web service. As part of a RESTful design, the service uses a variety of HTTP status codes to communicate state back to the caller. For instance, if I request a resource that doesn't exist, the service responds with a 404 status code. Likewise, if I pass in malformed parameters, the service responds with a 400 (Bad Request) status code. Silverlight 5 automatically converts these into WebExceptions. Is there anyway I can get SL to not throw exceptions but return a legitimate response object with the status code, etc set to the what was received so that I can decide how to handle the response in my code?
(To further clarify, it appears this is only the case for status codes in the 400 and 500 ranges.)
AFAIK, there is no solution to avoid exceptions. Worse than that, it might be hard or even impossible to get the actual HTTP code (I'm not certain there, I haven't tried too hard).
You'll probably want to develop an HTTP request tool that traps WebException and provide an error status to the caller.

How to initiate multiple HTTP requests asynchronously?

I'd like to start multiple HTTP requests rapidly after each other, without having to wait on the previous response to arrive. I've tried this using WebClient.UploadStringAsync, but this doesn't work. I'd like to efficiently implement the following scenario:
Send request 1
Send request 2
Send request 3
And in another thread:
Receive response 1
Receive response 2
Receive response 3
Can this be done in Silverlight?
I'd like to start multiple HTTP requests rapidly after each other, without having to wait on the previous response to arrive
That's called HTTP Pipelining (assuming you hope to use the same socket) and it's not supported by many proxies and gateway devices. I would be surprised if Silverlight tried to support it.
Yes it can be done. What leads you to believe that UploadStringAsync isn't working?
Here is my guess you are posting to ASP.NET with Sessions turned on (the default) right?
The requests will be queued at the server end because ASP.NET will only process one request for a specific Session at a time.

Resources