11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst http = require('http');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst server = http.createServer((req, res) => {
71cb0ef41Sopenharmony_ci  let corked = false;
81cb0ef41Sopenharmony_ci  const originalWrite = res.socket.write;
91cb0ef41Sopenharmony_ci  res.socket.write = common.mustCall((...args) => {
101cb0ef41Sopenharmony_ci    assert.strictEqual(corked, false);
111cb0ef41Sopenharmony_ci    return originalWrite.call(res.socket, ...args);
121cb0ef41Sopenharmony_ci  }, 5);
131cb0ef41Sopenharmony_ci  corked = true;
141cb0ef41Sopenharmony_ci  res.cork();
151cb0ef41Sopenharmony_ci  assert.strictEqual(res.writableCorked, res.socket.writableCorked);
161cb0ef41Sopenharmony_ci  res.cork();
171cb0ef41Sopenharmony_ci  assert.strictEqual(res.writableCorked, res.socket.writableCorked);
181cb0ef41Sopenharmony_ci  res.writeHead(200, { 'a-header': 'a-header-value' });
191cb0ef41Sopenharmony_ci  res.uncork();
201cb0ef41Sopenharmony_ci  assert.strictEqual(res.writableCorked, res.socket.writableCorked);
211cb0ef41Sopenharmony_ci  corked = false;
221cb0ef41Sopenharmony_ci  res.end('asd');
231cb0ef41Sopenharmony_ci  assert.strictEqual(res.writableCorked, res.socket.writableCorked);
241cb0ef41Sopenharmony_ci});
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciserver.listen(0, () => {
271cb0ef41Sopenharmony_ci  http.get({ port: server.address().port }, (res) => {
281cb0ef41Sopenharmony_ci    res.on('data', common.mustCall());
291cb0ef41Sopenharmony_ci    res.on('end', common.mustCall(() => {
301cb0ef41Sopenharmony_ci      server.close();
311cb0ef41Sopenharmony_ci    }));
321cb0ef41Sopenharmony_ci  });
331cb0ef41Sopenharmony_ci});
34