Skip to content

Instantly share code, notes, and snippets.

@bulton-fr
Created March 10, 2019 01:21
Show Gist options
  • Save bulton-fr/2f711ca44ab9e85996a4f343318f8bf2 to your computer and use it in GitHub Desktop.
Save bulton-fr/2f711ca44ab9e85996a4f343318f8bf2 to your computer and use it in GitHub Desktop.
When php-curl create a apache vhost mess, but not curl with shell
// Call by php-curl
bfw.bulton.fr:443 109.190.35.87 - - [10/Mar/2019:02:10:39 +0100] "GET /api/v4/users/bulton-fr/events?after=2018-03-04 HTTP/1.1" 400 3076 "-" "-"
// Call by shell_exec
gitlab.bulton.fr:443 109.190.35.87 - - [10/Mar/2019:02:10:39 +0100] "GET /api/v4/users/bulton-fr/events?after=2018-03-04 HTTP/1.1" 200 16304 "-" "curl/7.58.0"
<?php
/**
* phpinfo() :
* PHP Version : 7.3.2-3+ubuntu18.04.1+deb.sury.org+1
* cURL Information : 7.58.0
*
* curl --version
* curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1a zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
*/
$curl = curl_init();
$curlOpt = [];
//DEBUG
$verbose = fopen('php://temp', 'w+');
$curlOpt[CURLOPT_HEADER] = true;
$curlOpt[CURLOPT_VERBOSE] = true;
//$curlOpt[CURLINFO_HEADER_OUT] = true;
$curlOpt[CURLOPT_STDERR] = $verbose;
//END DEBUG */
$curlOpt[CURLOPT_URL] = 'https://gitlab.bulton.fr/api/v4/users/bulton-fr/events?after=2018-03-04';
$curlOpt[CURLOPT_RETURNTRANSFER] = true;
$curlOpt[CURLOPT_HTTPHEADER] = [
'PRIVATE-TOKEN : XXX'
];
curl_setopt_array($curl, $curlOpt);
$datas = curl_exec($curl);
$infos = curl_getinfo($curl);
curl_close($curl);
//DEBUG
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
var_dump($infos, $verboseLog, $datas);
//END DEBUG */
var_dump(shell_exec('curl -v --header "PRIVATE-TOKEN: XXX" https://gitlab.bulton.fr/api/v4/users/bulton-fr/events?after=2018-03-04 2>&1'));
array(30) {
["url"]=>
string(71) "https://gitlab.bulton.fr/api/v4/users/bulton-fr/events?after=2018-03-04"
["content_type"]=>
string(29) "text/html; charset=iso-8859-1"
["http_code"]=>
int(400)
["header_size"]=>
int(246)
["request_size"]=>
int(139)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0.270277)
["namelookup_time"]=>
float(5.3E-5)
["connect_time"]=>
float(0.05622)
["pretransfer_time"]=>
float(0.206694)
["size_upload"]=>
float(0)
["size_download"]=>
float(306)
["speed_download"]=>
float(1133)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(306)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0.270231)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(13) "91.121.169.23"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(443)
["local_ip"]=>
string(12) "192.168.1.84"
["local_port"]=>
int(54212)
["http_version"]=>
int(2)
["protocol"]=>
int(2)
["ssl_verifyresult"]=>
int(0)
["scheme"]=>
string(5) "HTTPS"
}
string(1139) "* Hostname gitlab.bulton.fr was found in DNS cache
* Trying 91.121.169.23...
* TCP_NODELAY set
* Connected to gitlab.bulton.fr (91.121.169.23) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: CN=gitlab.bulton.fr
* start date: Jan 15 10:22:59 2019 GMT
* expire date: Apr 15 10:22:59 2019 GMT
* subjectAltName: host "gitlab.bulton.fr" matched cert's "gitlab.bulton.fr"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
> GET /api/v4/users/bulton-fr/events?after=2018-03-04 HTTP/1.1
Host: gitlab.bulton.fr
Accept: */*
PRIVATE-TOKEN : XXX
< HTTP/1.1 400 Bad Request
< Date: Sun, 10 Mar 2019 01:10:39 GMT
< Server: Apache/2.4.25 (Debian)
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Content-Length: 306
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
* Closing connection 0
"
string(552) "HTTP/1.1 400 Bad Request
Date: Sun, 10 Mar 2019 01:10:39 GMT
Server: Apache/2.4.25 (Debian)
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Length: 306
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.25 (Debian) Server at bfw.bulton.fr Port 443</address>
</body></html>
"
string(15102) " % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 91.121.169.23...
* TCP_NODELAY set
* Connected to gitlab.bulton.fr (91.121.169.23) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
} [5 bytes data]
* (304) (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* (304) (IN), TLS handshake, Server hello (2):
{ [108 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [2560 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: CN=gitlab.bulton.fr
* start date: Jan 15 10:22:59 2019 GMT
* expire date: Apr 15 10:22:59 2019 GMT
* subjectAltName: host "gitlab.bulton.fr" matched cert's "gitlab.bulton.fr"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
} [5 bytes data]
> GET /api/v4/users/bulton-fr/events?after=2018-03-04 HTTP/1.1
> Host: gitlab.bulton.fr
> User-Agent: curl/7.58.0
> Accept: */*
> PRIVATE-TOKEN: XXX
>
{ [5 bytes data]
< HTTP/1.1 200 OK
< Date: Sun, 10 Mar 2019 01:10:40 GMT
< Server: nginx
< Content-Type: application/json
< Content-Length: 12248
< Vary: Accept-Encoding,Origin
< Cache-Control: max-age=0, private, must-revalidate
< Etag: W/"90cfbf2d0407fccfbe5dff8be0567b58"
< Link: <https://gitlab.bulton.fr/api/v4/users/bulton-fr/events?after=2018-03-04&id=bulton-fr&page=2&per_page=20&sort=desc>; rel="next", <https://gitlab.bulton.fr/api/v4/users/bulton-fr/events?after=2018-03-04&id=bulton-fr&page=1&per_page=20&sort=desc>; rel="first", <https://gitlab.bulton.fr/api/v4/users/bulton-fr/events?after=2018-03-04&id=bulton-fr&page=12&per_page=20&sort=desc>; rel="last"
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-Next-Page: 2
< X-Page: 1
< X-Per-Page: 20
< X-Prev-Page:
< X-Request-Id: ksVGR5ocvp4
< X-Runtime: 0.059935
< X-Total: 228
< X-Total-Pages: 12
< Strict-Transport-Security: max-age=31536000
<
{ [5 bytes data]
[{"project_id":50,"act...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment