Snippets tagged “http”
86 snippets use this tag.
- Adding header for HttpURLConnectionJava
To add a header to an HTTP request using HttpURLConnection, you can use the setRequestProperty method.
- Basic Knowledge About AngularJs Services and FactoriesAngularJs
AngularJs suggests Services and Factories to have global actions and variables for controllers and for many other AngularJs components. Gain a basic knowledge about AngularJs services and factories.
- Best practice multi language websitePHP
One best practice for implementing a multi-language website in PHP is to use a language detection library such as Text-Language-Detect.
- Bind value between Service and Controller/DirectiveAngularJs
To bind values set an interval inside controller/directive, and you you will have a variable inside your scope, which holds the data from server. Another way is to use AngularJS events. See how you can do it.
- Block direct access to a file over http but allow php script accessPHP
One way to block direct access to a file over HTTP but allow PHP script access is to use a .htaccess file in the same directory as the file.
- Calling a PHP function by onclick eventPHP
To call a PHP function using an onclick event, you will need to use a little bit of JavaScript.
- Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING errorPHP
The "net::ERR_INCOMPLETE_CHUNKED_ENCODING" error in Chrome is usually caused by a problem with the website you are trying to load.
- Create a Laravel Request object on the flyPHP
In Laravel, you can create a Request object on the fly by using the create method of the Request facade.
- Create a Maven project in Eclipse complains "Could not resolve archetype"Java
There could be several reasons why you are getting the error "Could not resolve archetype" when trying to create a Maven project in Eclipse.
- Curl and PHP - how can I pass a json through curl by PUT,POST,GETPHP
To pass a JSON object through cURL using the PUT method, you can use the following command:
- curl error 18 - transfer closed with outstanding read data remainingPHP
Error 18 means that the transfer was closed with outstanding read data remaining.
- curl posting with header application/x-www-form-urlencodedPHP
To make a POST request using curl and include a header of Content-Type: application/x-www-form-urlencoded, you can use the following command:
- Does file_get_contents() have a timeout setting?PHP
Yes, the file_get_contents function in PHP does have a timeout setting.
- doGet and doPost in ServletsJava
doGet and doPost are methods of the javax.servlet.http.HttpServlet class that are used to handle HTTP GET and POST requests, respectively.
- Doing HTTP requests FROM Laravel to an external APIPHP
To make an HTTP request from Laravel to an external API, you can use the HTTP client of your choice.
- file_get_contents behind a proxy?PHP
The file_get_contents function in PHP can be used to retrieve the contents of a file from a remote server.
- Get a JSON object from a HTTP responseJava
To get a JSON object from a HTTP response in Java, you can use the JSONObject class from the org.json library.
- Get all photos from Instagram which have a specific hashtag with PHPPHP
To get all photos from Instagram that have a specific hashtag with PHP, you can use the Instagram API.
- Get file content from URL?PHP
To get the contents of a file from a URL in PHP, you can use the file_get_contents function.
- Get latitude and longitude automatically using php, APIPHP
To get latitude and longitude automatically using PHP, you can use an API (Application Programming Interface) such as Google Maps API, OpenCage Geocoding API, or GeoCode.io API.
- Get the data received in a Flask requestPython
In a Flask application, you can access the data received in a request using the request object.
- How can I display the users profile pic using the facebook graph api?PHP
To display a user's profile picture using the Facebook Graph API in PHP, you can make a GET request to the /{user-id}/picture endpoint.
- How can I upload files to a server using JSP/Servlet?Java
To upload files to a server using JSP/Servlet, you can use the following steps:
- How do I do a HTTP GET in Java?Java
To send an HTTP GET request in Java, you can use the java.net.URL and java.net.HttpURLConnection classes.
- How do I get a YouTube video thumbnail from the YouTube API?PHP
To get a thumbnail image for a YouTube video in PHP, you can use the file_get_contentsfunction to make a GET request to the videos.list method of the YouTube Data API.
- How do I implement basic "Long Polling"?PHP
Here's an example of how you can implement Long Polling in PHP:
- How do I return a proper success/error message for JQuery .ajax() using PHP?PHP
To return a proper success/error message for jQuery.ajax() using PHP, you can do the following:
- How do you return a JSON object from a Java ServletJava
To return a JSON object from a Java Servlet, you can use the following steps:
- How Does the Access-Control-Allow-Origin Header WorkJavaScript
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 add http:// if it doesn't exist in the URLPHP
You can use the following code snippet to add "http://" to the beginning of a URL if it doesn't already exist:
- How to build a RESTful API?PHP
To build a RESTful API in PHP, you can use a framework such as Laravel or CodeIgniter, or you can build the API from scratch using core PHP.
- How to call a php script/function on a html button click?PHP
To call a PHP script or function on a HTML button click, you can use JavaScript to send an HTTP request to the server when the button is clicked.
- How to Create Ajax Submit Form Using jQueryJavaScript
This tutorial provides several methods of creating an Ajax submit form using jQuery easily. Read about the differences of the GET and POST HTTP methods.
- How to deploy a war file in Tomcat 7Java
To deploy a WAR (Web ARchive) file in Apache Tomcat 7, you can follow these steps:
- How to download a file over HTTP?Python
Import the "urllib" module:
- How to fix "set SameSite cookie to none" warning?PHP
To fix the "set SameSite cookie to none" warning in PHP, you will need to specify the SameSite attribute when you set the cookie.
- How to get page content using cURL?PHP
To get the content of a webpage using cURL, you can use the following command:
- How to Make HTTP GET Request in JavaScriptJavaScript
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 POST form data with Spring RestTemplate?Java
To POST form data with the RestTemplate class in Spring, you can use the postForObject method and pass it a URL, an object containing the form data, and the response type.
- How to print all information from an HTTP request to the screen, in PHPPHP
In PHP, you can use the $_SERVER superglobal array to access information about the current HTTP request.
- How to respond with an HTTP 400 error in a Spring MVC @ResponseBody method returning StringJava
To respond with an HTTP 400 error in a Spring MVC controller method that returns a String, you can throw a ResponseStatusException with a status of BAD_REQUEST.
- How to run my php file from mac terminal?PHP
To run a PHP file from the Mac terminal, you will need to have a web server installed, such as Apache, and PHP should be configured correctly with the server.
- How to send a GET request from PHP?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 PHPPHP
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?Java
In Java, you can send an HTTP request using the java.net.URL and java.net.HttpURLConnection classes.
- How to serve static files in FlaskPython
To serve static files in Flask, you will need to use the send_static_file method in your route function.
- How to upload a file and JSON data in Postman?Java
To upload a file and JSON data in Postman, you can follow these steps:
- How to use java.net.URLConnection to fire and handle HTTP requestsJava
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:
- How to use wget in php?PHP
You can use the exec function in PHP to execute the wget command.
- How to validate Google reCAPTCHA v3 on server side?PHP
To validate a Google reCAPTCHA v3 on the server side using PHP, you will need to do the following steps:
- Http 415 Unsupported Media type error with JSONJava
A HTTP 415 Unsupported Media Type error means that the server is unable to process the request because the request entity has a media type that the server does not support. In the context of a JSON request, this means that the server is unable to process
- HTTP authentication logout via PHPPHP
To log out a user from HTTP authentication using PHP, you can use the header function to send a "WWW-Authenticate" header with a value of "Basic realm=realmName" and a 401 status code.
- HTTP POST using JSON in JavaJava
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 codePHP
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:
- HttpServletRequest get JSON POST dataJava
To get JSON POST data from an HttpServletRequest object in Java, you can use the getReader method of the ServletRequest interface to read the request body as a BufferedReader and then use the readLine method to read the data as a string.
- Issue reading HTTP request body from a JSON POST in PHPPHP
In PHP, you can read the body of an HTTP request using the file_get_contents('php://input') function.
- Java - sending HTTP parameters via POST method easilyJava
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:
- JAX-RS — How to return JSON and HTTP status code together?Java
In JAX-RS, you can use the Response class from the javax.ws.rs.core package to return a JSON response and an HTTP status code together. Here's an example of how to do this:
- Main differences between SOAP and RESTful web services in JavaJava
SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) are two different styles of web services that can be used to expose the functionality of a web-based system over the internet.
- PHP - Copy image to my server direct from URLPHP
To copy an image from a URL and save it to your server using PHP, you can use the following function:
- PHP CURL DELETE requestPHP
To send a DELETE request with PHP using cURL, you can use the following code:
- PHP cURL how to add the User Agent value OR overcome the Servers blocking cURL requests?PHP
You can add a custom User Agent value to a cURL request in PHP using the CURLOPT_USERAGENT option.
- PHP cURL HTTP CODE return 0PHP
If cURL is returning a HTTP code of 0, it usually indicates that cURL was unable to communicate with the server.
- PHP cURL HTTP PUTPHP
To make an HTTP PUT request using PHP's cURL functions, you can use the following snippet:
- PHP header redirect 301 - what are the implications?PHP
A 301 redirect in PHP using the "header" function tells the browser that the page has permanently moved to a new location.
- PHP: HTTP or HTTPS?PHP
In PHP, you can use the $_SERVER['HTTPS'] variable to check whether the current page is being served over HTTPS.
- POST request via RestTemplate in JSONJava
To make a POST request with the RestTemplate in JSON, you can use the postForObject() method and pass it the URL of the request, the request body, the response type, and the HttpEntity object that represents the request headers and body.
- Post Requests with cURLPHP
cURL is applied for making requests with different protocols. A post request can send user collected data to a server. Find out how to do that accurately.
- reliable user browser detection with phpPHP
There are several ways to detect a user's browser using PHP.
- RESTful call in JavaJava
To make a RESTful call in Java, you can use the HttpURLConnection class.
- Save image from url with curl PHPPHP
To save an image from a URL using PHP and cURL, you can use the following function:
- Sending HTTP POST Request In JavaJava
To send an HTTP POST request in Java, you can use the java.net.URL and java.net.HttpURLConnection classes. Here is an example of how you can use these classes to send a POST request:
- Sending multiple data parameters with jQuery AJAXPHP
To send multiple data parameters with jQuery's $.ajax() function in PHP, you can use the data option and set it to an object with the data you want to send.
- Simple example to post to a Facebook fan page via PHP?PHP
Here is an example of how you can post to a Facebook fan page using the Facebook PHP SDK:
- Simple HTTP server in Java using only Java SE APIJava
To create a simple HTTP server in Java using only the Java SE API, you can use the java.net package.
- Simple PHP calculatorPHP
Sure!
- Simplest way to read JSON from a URL in JavaJava
To read JSON from a URL in Java, you can use the readJsonFromUrl() method from the JSON simple library.
- Spring RestTemplate GET with parametersJava
To perform a GET request with parameters using the RestTemplate in Spring, you can use the getForObject() method and pass it a URL with placeholders for the parameters, as well as a map of the parameter values.
- What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?PHP
Long-polling, WebSockets, Server-Sent Events (SSE), and Comet are all techniques used to enable real-time communication between a client (usually a web browser) and a server.
- What does %5B and %5D in POST requests stand for?Java
The strings "%5B" and "%5D" are URL-encoded versions of the square brackets "[" and "]", respectively.
- What exactly is Apache Camel?Java
Apache Camel is an open-source integration framework that provides a uniform interface for integrating various applications and protocols.
- What is the Python 3 equivalent of "python -m SimpleHTTPServer"Python
In Python 3, you can use the http.server module to run a simple HTTP server.
- What is the quickest way to HTTP GET in Python?Python
Here's a code snippet for making an HTTP GET request using the requests library in Python:
- What's the net::ERR_HTTP2_PROTOCOL_ERROR about?PHP
net::ERR_HTTP2_PROTOCOL_ERROR is an error that occurs in the Google Chrome browser when there is an issue with the HTTP/2 protocol.
- Which Tag is Better to Use: <embed> or <object>HTML
On this page, you will learn what is the difference between the HTML <embed> and <object> tags and which one is better to use. Read the snippet and find examples.
- WordPress Issue: Cannot modify header information - headers already sent byPHP
This error message appears when a PHP script is trying to modify the headers of an HTTP response after the headers have already been sent.