Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux System Getting Started Learning: the curl set custom HTTP header     - Use Linux built-in firewall to improve network access control (Linux)

- Log device files under Linux - logger (Linux)

- Install Oracle database error process of [INS-35172] (Database)

- 7 extremely dangerous Linux commands (Linux)

- Ubuntu 12.04 commonly use shortcuts finishing Share (Linux)

- Pydev installed and configured on the Eclipse (Linux)

- Parameters of the extra port MySQL 5.6 (Database)

- Android Studio Clear Project or Rebuild Project Error (Linux)

- Linux kernel likely and unlikely to resolve macro definitions (Linux)

- The OpenGL ES GLFW window structures (Programming)

- Tomcat configuration memory and remote debug port (Server)

- CentOS 6.4 dial-up Raiders (Linux)

- Oracle 11g + RAC + RHEL6.5 + udev + ASM + PSU installation summary (Database)

- HBase Application Development Review and Summary of Series (Database)

- Oracle 10g in the unique and index problems (Database)

- Taught you how to install Ubuntu Linux (Linux)

- CentOS 5.11 Open VNC access (Linux)

- How to find the available network adapter on Ubuntu (Linux)

- ORA-28000 the account is locked fault simulation (Database)

- Vagrant Getting Start (Linux)

 
         
  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: 157.166.226.25'-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.
     
         
       
         
  More:      
 
- How to run Docker client in Windows operating system (Linux)
- Detailed usage history command (Linux)
- B-tree - ideas and implementation of C language code (Programming)
- Linux System Getting Started Learning: Linux how to install 7zip (Linux)
- Linux Basic Course: Install the software from source code (Linux)
- Type Linux commands (Linux)
- AWR Report (Database)
- Ubuntu install VMware Workstation 11 tutorials at 14.04 / 14.10 (Linux)
- Docker use Dockerfile created since the launch of the service support SSH container mirror (Server)
- Caffe + Ubuntu 14.04 64bit + CUDA 6.5 configuration instructions (Linux)
- How to use Linux iptables tool for network sharing (Linux)
- Schema snapshot rollback (Database)
- Linux virtual machine settings network, hostname ssh access (Linux)
- Ubuntu 14.10 / 14.04 / 12.04 installation GNOME Pie 0.5.6 (Linux)
- Service Discovery: Zookeeper vs etcd vs Consul (Server)
- Oracle common internal event tracking number (Database)
- Use ARChon runtime environment to run Android apps on Ubuntu (Linux)
- Nginx1.8 version upgrade method AMH4.2 Free manually compile (Server)
- Introduction to thread pooling and simple implementation (Programming)
- How to Use Nmap security scanner tool on Linux (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.