How-to articles, tricks, and solutions about HTTP

Adding header for HttpURLConnection

To add a header to an HTTP request using HttpURLConnection, you can use the setRequestProperty method.

Detecting request type in PHP (GET, POST, PUT or DELETE)

In PHP, you can use the $_SERVER['REQUEST_METHOD'] superglobal to detect the request type.

Doing HTTP requests FROM Laravel to an external API

To make an HTTP request from Laravel to an external API, you can use the HTTP client of your choice.

How can I select and upload multiple files with HTML and PHP, using HTTP POST?

You can use the following HTML code to create a form that allows users to select and upload multiple files.

How do I do a HTTP GET in Java?

To send an HTTP GET request in Java, you can use the java.net.URL and java.net.HttpURLConnection classes.

How do I implement basic "Long Polling"?

Here's an example of how you can implement Long Polling in PHP:

How Does the Access-Control-Allow-Origin Header Work

Read this tutorial and learn about how the Access-Control-Allow-Origin response header works. Also, read about CORS, the origin, and non-simple requests.

How to Convert the Image into a Base64 String Using JavaScript

Read this tutorial and learn several methods of converting an image to a Base64 string using JavaScript. Choose the right approach for you and try examples.

How to disable output buffering in PHP

In PHP, you can disable output buffering by calling the ob_end_flush() function or flush() function.

How to Encode JavaScript Object to Query-String

Read this JavaScript tutorial and learn useful information about the two widely used methods that are used for encoding objects to query strings easily.

How to include Authorization header in cURL POST HTTP Request in PHP?

To include the Authorization header in a cURL POST request in PHP, you can use the CURLOPT_HTTPHEADER option and pass it an array of headers like this:

How to Make HTTP GET Request in JavaScript

Read the tutorial and learn the how to make an HTTP GET request in JavaScript and make an asynchronous request and handle the response inside event handler.

How to Manage a Redirect Request after a jQuery Ajax Call

In this JavaScript tutorial, you will read and learn detailed information about the method used for managing a redirect request after a jQuery Ajax call.

How to print all information from an HTTP request to the screen, in PHP

In PHP, you can use the $_SERVER superglobal array to access information about the current HTTP request.

How to Read Request Headers in PHP

The given snippet explores how to read request readers in PHP. Read it and learn the most helpful methods of reading any request headers in PHP.

How to send a GET request from PHP?

To send a GET request from PHP, you can use the file_get_contents function or the cURL extension.

How to Send a Post Request with PHP

In this snippet, we will share with you the most flexible and powerful ways of sending post requests with the help of PHP. Just check out the examples.

How to send HTTP request in Java?

In Java, you can send an HTTP request using the java.net.URL and java.net.HttpURLConnection classes.

How to use java.net.URLConnection to fire and handle HTTP requests

You can use the java.net.URLConnection class to fire and handle HTTP requests in Java. Here's an example of how you can use the URLConnection class to send a GET request and read the response:

Http Basic Authentication in Java using HttpClient?

To perform HTTP basic authentication in Java using the HttpClient library, you can use the UsernamePasswordCredentials class and the BasicCredentialsProvider class.

HTTP POST using JSON in Java

To make an HTTP POST request using JSON in Java, you can use the HttpURLConnection class available in the java.net package. Here's an example of how to do it:

HTTP requests with file_get_contents, getting the response code

To make an HTTP request using the file_get_contents function in PHP and retrieve the response code, you can use the following code snippet:

Java - sending HTTP parameters via POST method easily

To send HTTP parameters via the POST method in Java, you can use the java.net.URL and java.net.HttpURLConnection classes. Here is an example of how you can do this:

Java URL encoding of query string parameters

To URL encode the query string parameters of a URL in Java, you can use the URLEncoder class from the java.net package.

1 2