48780

Sending GET & POST requests in Java or other without responses

Question:

Is it possible to make GET & POST requests in Java or another language such that you don't care about what is returned?

As in just sending the requests but not wanting to receive any responses?

Answer1:

Whether you care about the response or not, it will be sent. The HTTP protocol specifications say that it must be.

If you don't care about the response, your client could just close the connection immediately after sending the request. But the chances are that you do want to know that the request was processed (i.e. the response status) even if you don't want to look at the contents of the response message.<br /> So maybe you could send the request and request body, and read the response status and then close the connection without reading the response body. However, this has a downside. It means that you can't reuse the HTTP connection to make further requests. The next request to the same server has to open a new connection.

Answer2:

You could use anynchronous HTTP requests if you don't care about the responses (that way your worker thread will not have to wait for the response to come back). See <a href="http://www.javaworld.com/javaworld/jw-03-2008/jw-03-asynchhttp.html" rel="nofollow">http://www.javaworld.com/javaworld/jw-03-2008/jw-03-asynchhttp.html</a> for some details on Asynchronous/Synchronous HTTP queries in Java. Then you can control if the anychronous thread does or does not handle the response (or any failure flagged on the communication) - as long as there were no TCP level failures on the request the connection will still be opened.

Answer3:

You can't control whether or not the server returns a response. Your code is free to ignore any response it receives.

Answer4:

It's pretty hard to not <em>get</em> responses because they're part of the HTTP protocol. but you can certainly <em>ignore</em> the responses.

Recommend

  • What is the better pratice: duplicate code or use goto statement? [closed]
  • How to create a for loop in R? [duplicate]
  • System.Data.SQLite BadImageFormatException with NHibernate, works finewhen standalone
  • Excel not inserting leading zero
  • Meteor: Block access to application if user's email is not verified
  • Authentication - JavaScript - Logout issue
  • What are zone turns?
  • phpmailer - How to verify a sent email arrived at its destination
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • Using an STL Iterator without initialising it
  • Ruby 1.8.6 Array#uniq not removing duplicate hashes
  • Configure Spring's MappingJacksonHttpMessageConverter
  • JSON encode and decode on PHP
  • Can't remove headers after they are sent
  • Fail:(TESTMODE) Transactions of this market type cannot be processed on this system
  • Possible to get mouse events fired when cursor is outside page?
  • AppleScript : find open tab in safari by name and open it
  • Object and struct member access and address offset calculation
  • Check for zero lines output from command over SSH
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • What does 'Language neutral' mean with regard to MAKELANGID?
  • How to use JavaScript to determine whether a file exists in a directory?
  • Assign variable to the value in HTML
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Admob requires api-13 or later can I not deploy on old API-8 phones?
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • NHibernate Validation Localization with S#arp Architecture
  • How can I send an e-mail from a vbs script
  • Accessing IRQ description array within a module and displaying action names
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Symfony2: How to get request parameter
  • When should I choose bucket sort over other sorting algorithms?
  • Display Images one by one with next and previous functionality
  • How do you troubleshoot character encoding problems?
  • log4net write single file for each call to log.info
  • Getting error when using KSoap library to consume .NET web services
  • Understanding cpu registers
  • Getting Messege Twice Using IMvxMessenger