If a POST call is sent and user kills browser before it's complete, does it finish? - api

I'm unsure of the contract of a POST call connection. For example, a web page initiates a POST call and on the API side, the code begins executing. Say the code takes a couple minutes to complete, but the user closes the browser, severing the client side of the POST call.
Does this cause the API code to stop executing? If not, what happens when it tries to response to the web page, but the web page isn't there?

Once the server receives the POST it starts executing it. It doesn't matter if the client closes the browser while the server is executing the POST.
When the server finishes the process and performs the response, it will sent to the client. Again, it doesn't matter if nobody receives it, it will try to send it.
Note: You can test the process with a proxy like Fiddler. Even if you close the browser you will see the server response.

Related

Multiple HTTP POST request when user only clicked once

We have a curious situation with http referrer and response.
Our application is a J2EE with a WEB and EJB project. Working fine for years.
Recently, from one specific location, when user click to submit, our EJB sysout picked up trace that there was more than one submit (POST request) resulting in a null pointer. Our button have been designed to be disabled after it has been clicked. We are not sure how a subsequent request can possibly happen. In this simulation of the problem, we click once and there is only one user in the system.
Since this only occur when we connect from a particular ISP. We do not experience multiple request from other ISP locations. So we are suspecting that the ISP may have in advertently trigger a resubmit. But we are not sure. What else can we do to trace the root cause of this problem.
Thanks for your help.
Update on 12-Apr
We have installed wireshark to trace the signal from the browser side. We notice that the browser concern makes a "retry" after every 11 or 12 minutes. Would this be a normal browser behaviour?
I think we have found the cause of the problem. It is explained by by this https://blogs.oracle.com/ravello/beware-http-requests-automatic-retries
It is something in the HTTP spec
"If an HTTP/1.1 client sends a request which includes a request body, but which does not include an Expect request-header field with the "100-continue" expectation, and if the client is not directly connected to an HTTP/1.1 origin server, and if the client sees the connection close before receiving any status from the server, the client SHOULD retry the request. W3 Hypertext Transfer Protocol -- HTTP/1.1

Writing tests with http request without response

I need to prepare a Java test (citrus framework) which initial step is sending a http request. Unfortunately my app under tests does not reply to this http request with anything while my testing framework expects to have a response and generates an error otherwise. The best way to deal with such a situation which came to my mind is to use some kind of a proxy between my testing framework and actual application which will forward the test request to the actual application and reply back to the testing framework with OK status not waiting for the response from app.
Does it make a sense? How could I prepare such a proxy assuming that my tests are to be running with maven invocation?
I see following options:
Fire and forget: send the Http request (using the fork mode on the send operation in Citrus) and do not care for the response at all. Just leave out the receive message action to ignore the response in Citrus.
Expect the timeout: Send the Http request and use the receive timeout action to verify that the client does not receive a response in the given time
Assert/catch the timeout exception: Use the assert or catch action in Citrus to handle the timeout exception when sending the http request
Personally I would go for the option #2 where you send the Http request and verify that there is no response for a given amount of time. This makes sure that the actual behavior of your application to not send any response does not change over time.

Is it possible for Apache to send a 'pause' or 'wait' response to client while running a PHP/Perl script?

When the Apache server receives a POST request, I want to immediately send back a response, stating that the client should wait and not send anything.
While at the same time client's request will be passed on to a script (either PHP or Perl). And then the script will send back a response to the client.
Is this possible? I know that it is possible for Apache to send a 4xx response header, so that the client would stop sending. But I want to run a script while the client has stopped sending and then have the client redirect to somewhere..
There are a few HTTP status codes that may be of use IF you want to be fully REST-ful and use the HTTP verbs (GET, POST, PUT, DELETE, etc) and status codes
https://www.restapitutorial.com/httpstatuscodes.html
In particular for what I am interpreting as your use case, status code 202 Accepted may be correct for your use:
The request has been accepted for processing, but the processing has
not been completed. The request might or might not eventually be acted
upon, as it might be disallowed when processing actually takes place.
There is no facility for re-sending a status code from an asynchronous
operation such as this.
The 202 response is intentionally non-committal. Its purpose is to
allow a server to accept a request for some other process (perhaps a
batch-oriented process that is only run once per day) without
requiring that the user agent's connection to the server persist until
the process is completed. The entity returned with this response
SHOULD include an indication of the request's current status and
either a pointer to a status monitor or some estimate of when the user
can expect the request to be fulfilled.

IIS 8 - How to view a history of requests made to the web server

I have a web server that is currently running my asp.net mvc website. I am making a connection to an external website that sends a request back to the server via a specific URL and attaches the information sent as a query string.
I have no idea if this query string being sent is in the correct format but I do know that the action result function is being called. I need to see what requests are being sent to the server so that I can see the format in which the request was sent.
I know how to view the currently executing requests using the request monitor, but this is not enough since you can miss the request if it happens to fast.
Is it possible to view a history of requests that have occurred on the server? So that I may find the one that I need after the request has occurred.

Blocking Request

What does a server connection with a blocking request mean?
Thank You!
It means, when you make a request to the server, you wait until you hear back from it (blocking).
The advantage of this approach is that code that expects the request to complete will be ensured that the request has completed.
The downsides are that your code is "hung" until the request completes, and there is a chance that the request might not ever complete, which results in a hung thread and/or process.
Typically blocking requests are accompanied by timeouts, so after period of time, if no response is given, the call returns with an error indicated a timeout has elapsed, and you should diligently handle that case.
Web page requests are an example of a blocking request. When you type www.google.com into your browser, your browser makes a blocking request to Google's web server, waiting to display the response. If (for some crazy reason) google doesn't respond, you'll get a timeout error.