Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Linux System Getting Started Learning: the curl set custom HTTP header     - MongoDB fragmentation (Cluster) (Database)

- JavaScript notes --Objects (Programming)

- EXP-00091 Error resolved (Database)

- MySQL 5.6.12 binary log path switching binlog (Database)

- Use the dd command to the hard disk I / O performance test (Linux)

- hadoop 2.7.1 High Availability Setup Deployment (Server)

- C ++ Fundamentals study notes (Programming)

- Fedora 20 installation source Xen4.3.0 (Linux)

- Configuring Allatori code confusion when developing general Java applications in NetBeans (Programming)

- In-depth understanding of capture Node.js garbage collection and memory leaks (Programming)

- Which file system is most suitable for your Linux system (Linux)

- The execution order of Oracle WHERE condition is not from right to left (Database)

- Linux boot process and run level (Linux)

- Oracle large table to clean truncate .. reuse storage (Database)

- SpringMVC garbage processing (Programming)

- Git uses a standard process (Linux)

- MySQL EXPLAIN SQL output description (Database)

- JBPM6 Tutorial - taught you how to install JBPM (Linux)

- Linux system package manager -RPM (Linux)

- Python Basics Tutorial - lambda keyword (Programming)

  Linux System Getting Started Learning: the curl set custom HTTP header
  Add Date : 2017-04-13      
  Question: I am trying to use the curl command to get a URL, but other than that I would like to set up some custom header field in outgoing HTTP request. How can I use a custom HTTP header in the curl in it?

curl is a powerful command-line tool that can pass information over the network to the server or to obtain data from the server. He supported many of the transport protocol, in particular HTTP / HTTPS, and others, such as FTP / FTPS, RTSP, POP3 / POP3S, SCP, IMAP / IMAPS protocols. When you use curl to send a URL HTTP request, it will use a default that contains only the necessary header fields (eg: User-Agent, Host, and Accept) HTTP header.

In a few cases, you might want to override the default HTTP header or add a new custom HTTP header field in a request. For example, you may want to rewrite the "HOST" field to test a load balancer, or by overriding the "User-Agent" string to impersonate a specific browser to resolve some of the access limits.

In order to solve all these problems, curl provides a simple way to complete control of the outgoing HTTP headers HTTP request. You need this parameter is "-H" or "--header".

In order to define multiple HTTP header field, "- H" option can be specified more than once in the curl command.

For example: The following command sets three HTTP header field. That is, rewrite the "HOST" field, and add the two fields ( "Accept-Language" and "Cookie")

$ Curl -H 'Host:'-H' Accept-Language: es'-H 'Cookie: ID = 1234' http://cnn.com

For the "User-Agent", "Cookie", "Host" HTTP header fields such standards, there is usually another setting method. curl command provides specific options to be set for these header fields:

-A (Or --user-agent): set the "User-Agent" field.
-b (or --cookie): Setting "Cookie" field.
-e (or --referer): Setting "Referer" field.
For example, the following two commands are equivalent. These two commands are the same for HTTP header "User-Agent" string changes.

$ Curl -H "User-Agent: my browser" http://cnn.com
$ Curl -A "my browser" http://cnn.com
wget is another similar curl, command-line tool can be used to obtain the URL. Wget and also allows you to use as a custom HTTP headers. Click here to view details wget command.
- Usage Linux device tree (Programming)
- swap space is insufficient cause OOM kill MySQL Case (Database)
- Installation and Configuration ISC DHCP server on Debian Linux (Server)
- SQL Server memory Misunderstanding (Database)
- Install the open source database PostgreSQL 9.4 and phpMyAdmin on Ubuntu (Database)
- How to add a new hard disk without restarting the CentOS 7 / RHEL 7 virtual machine (Linux)
- Realization of Linux operating system illegal IP censorship (Linux)
- Oracle 11g through SCN do incremental backup repair standby library detailed process (Database)
- PXE + Kickstart automatically install CentOS 6.5 (Linux)
- Using BBED repair ORA-01190 error (Database)
- The most commonly used Linux commands (Linux)
- Installing PHP Memcache extension under Linux (Server)
- Linux Network Programming - libnet Guide (Programming)
- Correlation Analysis: FP-Growth algorithm (Programming)
- To configure linux transparent firewall (Linux)
- Diagnose and resolve the SSH connection slow (Linux)
- Mac OS X system setup Google Go language development environment configuration tool Sublime Text 2 (Linux)
- ThinkPad X201i installation notes Debian 7.5 (Linux)
- RedHat Linux 6.4 install Oracle 10g error (Database)
- Use Ansible to bulk manage remote servers (Server)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.