Making sense of Apache HttpClient wire log from response - apache-httpclient-4.x

My application is using Apache HTTPClient 4.3.5 that sends HTTP request and gets response.
I am trying to figure out what response the app received.
Below is the log snippet -
[Jan 04 2015 05:38:14.109 AM] DEBUG wire:72 - http-outgoing-2 >> "POST /app HTTP/1.1[\r][\n]"
[Jan 04 2015 05:38:14.109 AM] DEBUG wire:72 - http-outgoing-2 >> "User-Agent: Mozilla/5.0[\r][\n]"
[Jan 04 2015 05:38:14.109 AM] DEBUG wire:72 - http-outgoing-2 >> "Content-Length: 47[\r][\n]"
[Jan 04 2015 05:38:14.109 AM] DEBUG wire:72 - http-outgoing-2 >> "Content-Type: application/x-www-form-urlencoded[\r][\n]"
[Jan 04 2015 05:38:14.109 AM] DEBUG wire:72 - http-outgoing-2 >> "Host: test.com[\r][\n]"
[Jan 04 2015 05:38:14.109 AM] DEBUG wire:72 - http-outgoing-2 >> "Connection: Keep-Alive[\r][\n]"
[Jan 04 2015 05:38:14.110 AM] DEBUG wire:72 - http-outgoing-2 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[Jan 04 2015 05:38:14.110 AM] DEBUG wire:72 - http-outgoing-2 >> "[\r][\n]"
[Jan 04 2015 05:38:14.489 AM] DEBUG wire:72 - http-outgoing-2 << "HTTP/1.1 200 OK[\r][\n]"
[Jan 04 2015 05:38:14.489 AM] DEBUG wire:72 - http-outgoing-2 << "Server: nginx[\r][\n]"
[Jan 04 2015 05:38:14.490 AM] DEBUG wire:72 - http-outgoing-2 << "Date: Sun, 04 Jan 2015 10:37:31 GMT[\r][\n]"
[Jan 04 2015 05:38:14.490 AM] DEBUG wire:72 - http-outgoing-2 << "Content-Type: text/html;charset=UTF-8[\r][\n]"
[Jan 04 2015 05:38:14.490 AM] DEBUG wire:72 - http-outgoing-2 << "Transfer-Encoding: chunked[\r][\n]"
[Jan 04 2015 05:38:14.490 AM] DEBUG wire:72 - http-outgoing-2 << "Connection: keep-alive[\r][\n]"
[Jan 04 2015 05:38:14.490 AM] DEBUG wire:72 - http-outgoing-2 << "Vary: Accept-Encoding[\r][\n]"
[Jan 04 2015 05:38:14.490 AM] DEBUG wire:72 - http-outgoing-2 << "Pragma: no-cache[\r][\n]"
[Jan 04 2015 05:38:14.490 AM] DEBUG wire:72 - http-outgoing-2 << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
[Jan 04 2015 05:38:14.491 AM] DEBUG wire:72 - http-outgoing-2 << "Cache-Control: no-cache[\r][\n]"
[Jan 04 2015 05:38:14.491 AM] DEBUG wire:72 - http-outgoing-2 << "Cache-Control: no-store[\r][\n]"
[Jan 04 2015 05:38:14.491 AM] DEBUG wire:72 - http-outgoing-2 << "Set-Cookie: JSESSIONID=0C1444D7E0FA6B0F3CCE20AFBA28237E; Path=/; HttpOnly[\r][\n]"
[Jan 04 2015 05:38:14.491 AM] DEBUG wire:72 - http-outgoing-2 << "Front-End-Https: on[\r][\n]"
[Jan 04 2015 05:38:14.491 AM] DEBUG wire:72 - http-outgoing-2 << "Content-Encoding: gzip[\r][\n]"
[Jan 04 2015 05:38:14.491 AM] DEBUG wire:72 - http-outgoing-2 << "[\r][\n]"
[Jan 04 2015 05:38:14.491 AM] DEBUG wire:72 - http-outgoing-2 << "37[\r][\n]"
[Jan 04 2015 05:38:14.492 AM] DEBUG wire:72 - http-outgoing-2 << "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x3][0xb3])J-.[0xc8][0xcf]+N[0xb5][0xe3][0xb2][0x81]1[0xe3][0x93][0xf3]S[0x80][0xfc][0xe0][0xd2][0xe4][0xe4][0xd4][0xe2]b.[0x1b]}4[0x9][0x84][0x80][0x1d][0x17][0x0]<Xn]#[0x0][0x0][0x0][\r][\n]"
[Jan 04 2015 05:38:14.492 AM] DEBUG wire:72 - http-outgoing-2 << "0[\r][\n]"
[Jan 04 2015 05:38:14.492 AM] DEBUG wire:72 - http-outgoing-2 << "[\r][\n]"
At first, I thought "[0x1f][0x8b][0x8][0x0][0x0]..." is hex string but there are non-hex string such as ")J-." and "+N." and each debug line is ending with "[\r][\n]". How would I be able to determine what response the app received.
I have spent quite few hours trying to find the answer but was unsuccessful.
Does it have to do anything with gzip compression or chunked transfer encoding?
Your help would be greatly appreciated if you could answer it.
Thanks,
James

HttpClient wire log replaces character 10 with [\n], character 13 with [\r], characters < 32 and > 127 (non-printable) with [0xN] where N is char's hexadecimal representation.
The reason you are seeing a lot of non-printable chars is indeed GZIP content encoding.

This is an old post, but I've just spent too much time looking for code to take such a log entry and decode/unzip it to a readable string. So here's my contribution:
public void parseHexReponse() throws IOException {
// make sure NOT to delete any spaces which are part of the payload!
final String responseHex = "[0x1f]...[0x0]"; // paste your response here
final String[] parts = responseHex.split("[\\[\\]]+");
final byte[] data = new byte[responseHex.length() / 3];
int idx = 0;
for (final String s : parts) {
if (s.startsWith("0x")) {
data[idx] = (byte) Integer.parseInt(s.substring(2), 16);
idx++;
} else if ("\\n".equals(s)) {
data[idx] = 10;
idx++;
} else if ("\\r".equals(s)) {
data[idx] = 13;
idx++;
} else {
for (final byte b : s.getBytes()) {
data[idx] = b;
idx++;
}
}
}
try (GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(Arrays.copyOfRange(data, 0, idx)));
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
final byte[] buffer = new byte[1024];
int len;
while ((len = gis.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
System.out.println(new String(out.toByteArray()));
}
}

http://moznion.github.io/PrettyWireLogViewer/
This tool decodes ugly httpclient format to human-readable.

Related

Ubuntu starting mysql/mysql server

I'm trying to restart my mysql/mysqld service on my ubuntu server but I keep getting the same errors.
I'm using mysql version: 8.0.23
Ubuntu version: Ubuntu 20.04.2 LTS
systemctl status mysql.service output:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2021-03-27 17:15:22 UTC; 10s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 125121 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 125175 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 125175 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Mar 27 17:13:41 server systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Mar 27 17:13:41 server systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 27 17:13:41 server systemd[1]: Stopped MySQL Community Server.
Mar 27 17:13:41 server systemd[1]: Starting MySQL Community Server...
Mar 27 17:15:22 server systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Mar 27 17:15:22 server systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 27 17:15:22 server systemd[1]: Failed to start MySQL Community Server.
journalctl -xe output:
--
-- A start job for unit mysql.service has finished with a failure.
--
-- The job identifier is 26786 and the job result is failed.
Mar 27 17:15:39 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=52 TOS>
Mar 27 17:15:57 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=52 TOS>
Mar 27 17:16:19 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=48 TOS>
Mar 27 17:16:38 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=52 TOS>
Mar 27 17:16:57 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=52 TOS>
Mar 27 17:17:01 server CRON[125231]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar 27 17:17:01 server CRON[125232]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Mar 27 17:17:01 server CRON[125231]: pam_unix(cron:session): session closed for user root
Mar 27 17:17:16 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=48 TOS>
Mar 27 17:17:24 server sshd[125236]: error: kex_exchange_identification: Connection closed by remote host
Mar 27 17:17:37 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=48 TOS>
Mar 27 17:17:56 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=52 TOS>
Mar 27 17:18:03 server sshd[125237]: Unable to negotiate with 68.183.4.74 port 49612: no matching key exchange method found. Their offer: diffie-hellm>
Mar 27 17:18:17 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=40 TOS=>
Mar 27 17:18:30 server systemd[1]: fwupd.service: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit fwupd.service has successfully entered the 'dead' state.
Mar 27 17:18:35 server hv_kvp_daemon[125265]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dns_info: not found
Mar 27 17:18:35 server hv_kvp_daemon[125267]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dhcp_info: not found
Mar 27 17:18:35 server hv_kvp_daemon[125275]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dns_info: not found
Mar 27 17:18:35 server hv_kvp_daemon[125277]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dhcp_info: not found
Mar 27 17:18:39 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=48 TOS>
Mar 27 17:18:59 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=52 TOS>
Mar 27 17:19:17 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=MACADDRESS SRC=SRCADDRESS DST=SERVER_IP LEN=52 TOS>
Edit 1: new systemctl status mysql.service output
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2021-03-27 18:20:26 UTC; 28s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 135987 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 136026 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 136026 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 17 (File exists)
Mar 27 18:20:24 emkes-vps systemd[1]: Starting MySQL Community Server...
Mar 27 18:20:26 emkes-vps systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Mar 27 18:20:26 emkes-vps systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 27 18:20:26 emkes-vps systemd[1]: Failed to start MySQL Community Server.
journalctl -xe output:
Mar 27 18:22:21 emkes-vps hv_kvp_daemon[136366]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dns_info: not found
Mar 27 18:22:21 emkes-vps hv_kvp_daemon[136368]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dhcp_info: not found
Mar 27 18:22:21 emkes-vps hv_kvp_daemon[136376]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dns_info: not found
Mar 27 18:22:21 emkes-vps hv_kvp_daemon[136378]: sh: 1: /usr/libexec/hypervkvpd/hv_get_dhcp_info: not found

How can I do FOCAL MECHANISMS on Generic Mapping Tools (GMT)?

I've made some FOCAL MECHANISMS (FM) for the north part of Southamerica on GMT, and I need to put them on a map.
For the FM I have a document with 85 earthquakes and this is the code:
psmeca eventos2.dat -R-80/-66/-5/14 -JM6i -Sm0.4/0/0.05u -P -V > coltopomap.ps
GMT psconvert coltopomap.ps -Tf
And this is the map
GMT grdcut topo15.grd -R-80/-66/-5/14 -Gtopo15_cut_col.grd
GMT grdgradient topo15_cut_col.grd -Gtopo15_cut_shaded.grd -A310 -Ne0.6
GMT grdimage topo15_cut_col.grd -JM6i -R-80/-66/-5/14 -Cglobe -P -Ba --MAP_FRAME_TYPE=plain --MAP_GRID_CROSS_SIZE_PRIMARY=0p -Itopo15_cut_shaded.grd -K > coltopomap.ps
GMT pscoast -R-80/-66/-5/14 -J -Df -N1/1,black -W1/0.5,black -Lf-68/-4/-68/-4/200k+l -Tdg-78/12+w0.3i+f3+lW,E,S,N --FONT_ANNOT=10p --FONT_LABEL=10p --FONT_TITLE=10p -O >> coltopomap.ps
To join them I've tried with
GMT grdcut topo15.grd -R-80/-66/-5/14 -Gtopo15_cut_col.grd
GMT grdgradient topo15_cut_col.grd -Gtopo15_cut_shaded.grd -A310 -Ne0.6
GMT grdimage topo15_cut_col.grd -JM6i -R-80/-66/-5/14 -Cglobe -P -Ba --MAP_FRAME_TYPE=plain --MAP_GRID_CROSS_SIZE_PRIMARY=0p -Itopo15_cut_shaded.grd -K > coltopomap.ps
GMT pscoast -R-80/-66/-5/14 -J -Df -N1/1,black -W1/0.5,black -Lf-68/-4/-68/-4/200k+l -Tdg-78/12+w0.3i+f3+lW,E,S,N --FONT_ANNOT=10p --FONT_LABEL=10p --FONT_TITLE=10p -O >> coltopomap.ps
GMT psmeca eventos2.dat -R-80/-66/-5/14 -JM6i -Sm0.4/0/0.05u -P -V >> coltopomap.ps
GMT psconvert coltopomap.ps -Tf
But the only thing I get is the map in one page and the FM in another as you can see in the next image:
https://i.stack.imgur.com/bAvx7.png
It seems you are missing the -K flag from your GMT pscoast ... command.
From GMT documentation:
Required for all but the last plot command when building multi-layer
plots

ESP8266 client connection to MongoDB

I'm trying to post a new record to my MongoDB (actual CouchDB), but it seems that I'm having problems with the format of my request.
I'm using the following code:
(not showing debug and validations)
WiFiClient client;
client.connect("172.16.1.4", 5984)
String connStr = "POST /iot/ HTTP/1.1\r\n"
"Host: user:password#172.16.1.4:5984/ \r\n"
"Content-Type: application/json\r\n"
"\r\n"
"'{\"a\":1}'\r\n\r\n";
client.print(connStr);
I get this response back:
HTTP/1.1 400 Bad Request
Server: CouchDB/1.6.1 (Erlang OTP/18)
Date: Sat, 07 Oct 2017 11:57:50 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 48 Cache-Control: must-revalidate
{"error":"bad_request","reason":"invalid_json"}
HTTP/1.1 400 Bad
Request Server: MochiWeb/1.0 (Any of you quaids got a smint?)
Date: Sat, 07 Oct 2017 11:57:50 GMT
Content-Length: 0
I have tried with differet json/data...
Using Linux - I have no problems:
curl -X POST user:password#172.16.1.4:5984/iot/ -H "Content-Type: application/json" -d '{"a":3}'
The issue might be with the single quotes(') before { and at the end of }
instead of
"'{\"a\":1}'\r\n\r\n"
it should be
"{\"a\":1}\r\n\r\n"
I was missing the line:
"Content-Length: " + String(json.length()) + "\r\n"
in the header.

How to test a REQUEST GET in Acceptance Test

I am testing a script for logout and access a URL not accessible when you are not logged in, but in my URL LOGOUT, i get the response code 405 and this is problematic.
Code:
$I = new AcceptanceTester($scenario);
$I->amOnPage('/financeiro_legado/finlegado-titulo/index');
$I->wantTo('Logout');
$I->amOnPage('/');
$I->fillField('LoginForm[username]', 'marcelo');
$I->fillField('LoginForm[password]', 'marceloid5123');
$I->click('#login-form .btn');
$I->see('Olá, marcelo');
$I->seeInCurrentUrl('/');
$I->click('Logout', '.nav');
$I->amOnPage('/financeiro_legado/finlegado-titulo/index');
Returns:
Logout (LogoutCept)
Scenario:
* I am on page "/financeiro_legado/finlegado-titulo/index"
[Response] 200
[Page] http://10.0.0.10/CliPainel/backend/web/index.php/user-management/auth/login
[Cookies] {"PHPSESSID":"puu268lb5rjl00ml0hk27rm9b0"}
[Headers] {"Date":["Fri, 11 Dec 2015 17:34:13 GMT"],"Server":["Apache/2.4.17 (Ubuntu)"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Cache-Control":["no-store, no-cache, must-revalidate, post-check=0, pre-check=0"],"Pragma":["no-cache"],"Set-Cookie":["_csrf=07c2d101d6c9e8530f7da67a78d451400eea99b70dc8a722a512661501bc4619a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%2248-nrt97Wc-EEUA0jUh6-USBTS-44ccy%22%3B%7D; path=/; httponly"],"Vary":["Accept-Encoding"],"Content-Length":["3918"],"Content-Type":["text/html; charset=UTF-8"]}
* I am on page "/"
[Response] 200
[Page] http://10.0.0.10/CliPainel/backend/web/index.php/user-management/auth/login
[Cookies] {"PHPSESSID":"puu268lb5rjl00ml0hk27rm9b0","_csrf":"07c2d101d6c9e8530f7da67a78d451400eea99b70dc8a722a512661501bc4619a:2:{i:0;s:5:"_csrf";i:1;s:32:"48-nrt97Wc-EEUA0jUh6-USBTS-44ccy";}"}
[Headers] {"Date":["Fri, 11 Dec 2015 17:34:14 GMT"],"Server":["Apache/2.4.17 (Ubuntu)"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Cache-Control":["no-store, no-cache, must-revalidate, post-check=0, pre-check=0"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Content-Length":["3918"],"Content-Type":["text/html; charset=UTF-8"]}
* I fill field "LoginForm[username]","marcelo"
* I fill field "LoginForm[password]","marceloid5123"
* I click "#login-form .btn"
[Uri] http://10.0.0.10/CliPainel/backend/web/index.php/user-management/auth/login
[Method] POST
[Parameters] {"_csrf":"bWN1ZS1zWTBZW1gLXwdgBzoAWCBoJhgABzYdUwAmCnI5MFhRGRA6SQ==","LoginForm":{"username":"marcelo","password":"marceloid5123"}}
[Response] 200
[Page] http://10.0.0.10/CliPainel/backend/web/
[Cookies] {"PHPSESSID":"6hehrk4ddoroplv5so3l6klkb1","_csrf":"07c2d101d6c9e8530f7da67a78d451400eea99b70dc8a722a512661501bc4619a:2:{i:0;s:5:"_csrf";i:1;s:32:"48-nrt97Wc-EEUA0jUh6-USBTS-44ccy";}"}
[Headers] {"Date":["Fri, 11 Dec 2015 17:34:16 GMT"],"Server":["Apache/2.4.17 (Ubuntu)"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Cache-Control":["no-store, no-cache, must-revalidate, post-check=0, pre-check=0"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Transfer-Encoding":["chunked"],"Content-Type":["text/html; charset=UTF-8"]}
* I see "Olá, marcelo"
* I see in current url "/"
* I click "Logout",".nav"
[Response] 405
[Page] http://10.0.0.10/CliPainel/backend/web/index.php/site/logout
[Cookies] {"PHPSESSID":"6hehrk4ddoroplv5so3l6klkb1","_csrf":"07c2d101d6c9e8530f7da67a78d451400eea99b70dc8a722a512661501bc4619a:2:{i:0;s:5:"_csrf";i:1;s:32:"48-nrt97Wc-EEUA0jUh6-USBTS-44ccy";}"}
[Headers] {"Date":["Fri, 11 Dec 2015 17:34:18 GMT"],"Server":["Apache/2.4.17 (Ubuntu)"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Cache-Control":["no-store, no-cache, must-revalidate, post-check=0, pre-check=0"],"Pragma":["no-cache"],"Allow":["POST"],"Transfer-Encoding":["chunked"],"Content-Type":["text/html; charset=UTF-8"]}
* I am on page "/financeiro_legado/finlegado-titulo/index"
[Response] 200
[Page] http://10.0.0.10/CliPainel/backend/web/financeiro_legado/finlegado-titulo/index
[Cookies] {"PHPSESSID":"6hehrk4ddoroplv5so3l6klkb1","_csrf":"07c2d101d6c9e8530f7da67a78d451400eea99b70dc8a722a512661501bc4619a:2:{i:0;s:5:"_csrf";i:1;s:32:"48-nrt97Wc-EEUA0jUh6-USBTS-44ccy";}"}
[Headers] {"Date":["Fri, 11 Dec 2015 17:34:19 GMT"],"Server":["Apache/2.4.17 (Ubuntu)"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Cache-Control":["no-store, no-cache, must-revalidate, post-check=0, pre-check=0"],"Pragma":["no-cache"],"Vary":["Accept-Encoding"],"Transfer-Encoding":["chunked"],"Content-Type":["text/html; charset=UTF-8"]}
PASSED
Probably you handle that click with Javascript in the web browser.
Yii2 module of Codeception does not execute Javascript.
Your options are:
a) make your site work with Javascript disabled.
You could achieve that by changing
Logout
To
<form method="POST" action="site/logout">
<input type="submit" value="Logout" />
</form>
b) Use sendAjaxPostRequest method to make POST request
$I->sendAjaxPostRequest('site/logout', []);

Image not stored in cache even though headers are set

The last few hours, I have tried to figure out, why the following image is not cached in the browser, after it is requested the first time:
http://runrpg.net/assets/images/screenshots/placeit_outdoor_wide.jpg
I understand that the correct headers have to be set, and currently the response header looks like this:
HTTP/1.1 200 OK
Date: Sat, 04 Jan 2014 16:35:53 GMT
Server: Apache/2.4.4 (Unix) OpenSSL/1.0.1e PHP/5.5.3 mod_perl/2.0.8-dev
Perl/v5.16.3
Last-Modified: Sat, 30 Nov 2013 01:37:52 GMT
ETag: "1dac5-4ec5afebf3c00-gzip"
Accept-Ranges: bytes
Cache-Control: max-age=2592000
Expires: Mon, 03 Feb 2014 16:35:53 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: image/jpeg
As you can see, the "Expires" header is set to "Mon, 03 Feb 2014 16:35:53 GMT" and I also included a "Cache-Control: max-age=2592000".
Can you help me and tell me what I am missing?
Your help would be very much appreciated.
Thanks!
This is most likely due to your server not validating ETags correctly. While cache validation through the Last-Modified header works perfectly:
$ HEAD -H "If-Modified-Since: Sat, 30 Nov 2013 01:37:52 GMT" http://runrpg.net/assets/images/screenshots/placeit_outdoor_wide.jpg
304 Not Modified
Cache-Control: max-age=290304000, public
Connection: close
Date: Sat, 04 Jan 2014 19:01:30 GMT
ETag: "1dac5-4ec5afebf3c00"
Server: Apache/2.4.4 (Unix) OpenSSL/1.0.1e PHP/5.5.3 mod_perl/2.0.8-dev Perl/v5.16.3
Expires: Thu, 09 Jan 2014 19:01:30 GMT
Client-Date: Sat, 04 Jan 2014 19:01:30 GMT
Client-Peer: 80.70.3.110:80
Client-Response-Num: 1
The same cannot be said with ETags:
$ HEAD -H 'If-None-Match: "1dac5-4ec5afebf3c00-gzip"' http://runrpg.net/assets/images/screenshots/placeit_outdoor_wide.jpg
200 OK
Cache-Control: max-age=290304000, public
Connection: close
Date: Sat, 04 Jan 2014 19:02:24 GMT
Accept-Ranges: bytes
ETag: "1dac5-4ec5afebf3c00"
Server: Apache/2.4.4 (Unix) OpenSSL/1.0.1e PHP/5.5.3 mod_perl/2.0.8-dev Perl/v5.16.3
Vary: Accept-Encoding
Content-Length: 121541
Content-Type: image/jpeg
Expires: Thu, 09 Jan 2014 19:02:24 GMT
Last-Modified: Sat, 30 Nov 2013 01:37:52 GMT
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: origin, x-requested-with, content-type, X-Titanium-Id
Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS
Access-Control-Allow-Origin: http://127.0.0.1:8020
Client-Date: Sat, 04 Jan 2014 19:02:24 GMT
Client-Peer: 80.70.3.110:80
Client-Response-Num: 1
Bottom line: The problem is your server, not any clients. This seems to be a known issue with Apache 2.4.x. A quick solution to this is by switching ETags off:
FileETag None