Set cURL to use local virtual hosts

后端 未结 7 1671
囚心锁ツ
囚心锁ツ 2020-11-28 01:37

Using Apache or Ngnix I always create development sites based on real projects such as http://project1.loc which, after adding to my .hosts file, t

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 01:44

    Making a request to

    C:\wnmp\curl>curl.exe --trace-ascii -H 'project1.loc' -d "uuid=d99a49d846d5ae570
    667a00825373a7b5ae8e8e2" http://project1.loc/Users/getSettings.xml
    

    Resulted in the -H log file containing:

    == Info: Could not resolve host: 'project1.loc'; Host not found
    == Info: Closing connection #0
    == Info: About to connect() to project1.loc port 80 (#0)
    == Info:   Trying 127.0.0.1... == Info: connected
    == Info: Connected to project1.loc (127.0.0.1) port 80 (#0)
    => Send header, 230 bytes (0xe6)
    0000: POST /Users/getSettings.xml HTTP/1.1
    0026: User-Agent: curl/7.19.5 (i586-pc-mingw32msvc) libcurl/7.19.5 Ope
    0066: nSSL/1.0.0a zlib/1.2.3
    007e: Host: project1.loc
    0092: Accept: */*
    009f: Content-Length: 45
    00b3: Content-Type: application/x-www-form-urlencoded
    00e4: 
    => Send data, 45 bytes (0x2d)
    0000: uuid=d99a49d846d5ae570667a00825373a7b5ae8e8e2
    <= Recv header, 24 bytes (0x18)
    0000: HTTP/1.1 403 Forbidden
    <= Recv header, 22 bytes (0x16)
    0000: Server: nginx/0.7.66
    <= Recv header, 37 bytes (0x25)
    0000: Date: Wed, 11 Aug 2010 15:37:06 GMT
    <= Recv header, 25 bytes (0x19)
    0000: Content-Type: text/html
    <= Recv header, 28 bytes (0x1c)
    0000: Transfer-Encoding: chunked
    <= Recv header, 24 bytes (0x18)
    0000: Connection: keep-alive
    <= Recv header, 25 bytes (0x19)
    0000: X-Powered-By: PHP/5.3.2
    <= Recv header, 56 bytes (0x38)
    0000: Set-Cookie: SESSION=m9j6caghb223uubiddolec2005; path=/
    <= Recv header, 57 bytes (0x39)
    0000: P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
    <= Recv header, 2 bytes (0x2)
    0000: 
    <= Recv data, 118 bytes (0x76)
    0000: 6b
    0004: HTTP/1.1 403 ForbiddenHTTP/1.1 403 Forbidden
    0071: 0
    0074: 
    == Info: Connection #0 to host project1.loc left intact
    == Info: Closing connection #0
    

    My hosts file looks like:

    # Copyright (c) 1993-1999 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    
    127.0.0.1       localhost
    ...
    ...
    127.0.0.1   project1.loc
    

提交回复
热议问题