dotnetnoob
dotnetnoob

Reputation: 11340

What does an httppost return by default?

I'm currently working with a number of third parties, sending them data via an HttpPost with an encrypted url string. Each of the third parties sends back an xml string which I then read and use. All is good!

The question I have is this. If I send a request to a third party, and they do not provide a response, what happens? To clarify, I mean that a response string isn't returned in all cases - not just errors and timeouts.

Upvotes: 0

Views: 74

Answers (2)

sampathsris
sampathsris

Reputation: 22280

Few things can happen:

  • A response is sent by the third party: It consists of the desired output (an XML string in your case.
  • A response is sent, but the content is 0 length: Take it into mind that HTTP response consists of two parts: HTTP headers, and content. In this case third party sends only the headers. You can consider this as String.Empty output.
  • A response is not sent: Third part should have sent a response according to the HTTP protocol, but they don't. Third party may close the socket or just timeout. That can happen because of an internal problem, or they are just choosing not to respond to you. This will normally result in an exception. What the exception is, though, depends on the methods/library you use to send HTTP requests.

Upvotes: 2

usr
usr

Reputation: 171188

The HTTP protocol does not include a way to not send a response. A response is always sent. It might be zero length, though.

I mean that a response string isn't returned in all cases

Is this a question or an assertion? This statement is false.

and they do not provide a response, what happens?

So what happens in case of a zero-length response? That depends entirely on your code. Neither protocol not framework care about this case.

Couldn't the socket actually be closed before any headers are sent back? Or, if the server is down?

That's a protocol violation. That's not HTTP, then. In such a situation the app is generally notified through an exception.

Upvotes: 1

Related Questions