diff --git a/build/docs/content/02-clients.md b/build/docs/content/02-clients.md index 560601e6..39bcd0cc 100644 --- a/build/docs/content/02-clients.md +++ b/build/docs/content/02-clients.md @@ -18,7 +18,7 @@ Unless your project already has a PSR7 `HttpClient`, install `php-http/guzzle6-a $ composer require php-http/guzzle6-adapter ``` -Then the PHP client: +Then the [PHP client](https://github.com/thecodingmachine/gotenberg-php-client): ```bash $ composer require thecodingmachine/gotenberg-php-client diff --git a/build/docs/content/04-html.md b/build/docs/content/04-html.md index 060da6ef..00a5fb8c 100644 --- a/build/docs/content/04-html.md +++ b/build/docs/content/04-html.md @@ -59,7 +59,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` @@ -146,7 +146,7 @@ $footer = DocumentFactory::makeFromPath('footer.html', 'footer.html'); $request = new HTMLRequest($index); $request->setHeader($header); $request->setFooter($footer); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` @@ -237,7 +237,7 @@ $assets = [ ]; $request = new HTMLRequest($index); $request->setAssets($assets); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` @@ -296,7 +296,7 @@ $request = new HTMLRequest($index); $request->setPaperSize(Request::A4); $request->setMargins(Request::NO_MARGINS); $request->setLandscape(true); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` @@ -345,7 +345,7 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client() $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); $request->setWaitDelay(5.5); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` @@ -397,6 +397,6 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client() $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); $request->setGoogleChromeRpccBufferSize(1048576); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` diff --git a/build/docs/content/05-url.md b/build/docs/content/05-url.md index 7795b833..900f91f5 100644 --- a/build/docs/content/05-url.md +++ b/build/docs/content/05-url.md @@ -51,7 +51,7 @@ use TheCodingMachine\Gotenberg\URLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); $request = new URLRequest('https://google.com'); $request->setMargins(Request::NO_MARGINS); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` @@ -85,4 +85,13 @@ $ curl --request POST \ ### PHP -// TODO \ No newline at end of file +```php +use TheCodingMachine\Gotenberg\Client; +use TheCodingMachine\Gotenberg\URLRequest; + +$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); +$request = new URLRequest('https://google.com'); +$request->addRemoteURLHTTPHeader('Your-Header', 'Foo') +$dest = 'result.pdf'; +$client->store($request, $dest); +``` diff --git a/build/docs/content/06-markdown.md b/build/docs/content/06-markdown.md index 66c50ee4..65b71702 100644 --- a/build/docs/content/06-markdown.md +++ b/build/docs/content/06-markdown.md @@ -65,6 +65,6 @@ $markdowns = [ DocumentFactory::makeFromPath('file.md', 'file.md'), ]; $request = new MarkdownRequest($index, $markdowns); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` diff --git a/build/docs/content/07-office.md b/build/docs/content/07-office.md index 39e91e37..70a1e2fa 100644 --- a/build/docs/content/07-office.md +++ b/build/docs/content/07-office.md @@ -64,7 +64,7 @@ $files = [ DocumentFactory::makeFromPath('document2.docx', 'document2.docx'), ]; $request = new OfficeRequest($files); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` @@ -112,6 +112,6 @@ $files = [ ]; $request = new OfficeRequest($files); $request->setLandscape(true); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` diff --git a/build/docs/content/08-merge.md b/build/docs/content/08-merge.md index 49ac0b2b..fc0d50ba 100644 --- a/build/docs/content/08-merge.md +++ b/build/docs/content/08-merge.md @@ -50,6 +50,6 @@ $files = [ DocumentFactory::makeFromPath('file2.pdf', 'file2.pdf'), ]; $request = new MergeRequest($files); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` diff --git a/build/docs/content/09-timeout.md b/build/docs/content/09-timeout.md index 9392b84f..7c644cec 100644 --- a/build/docs/content/09-timeout.md +++ b/build/docs/content/09-timeout.md @@ -48,6 +48,6 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client() $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); $request->setWaitTimeout(2.5); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); ``` diff --git a/build/docs/content/10-webhook.md b/build/docs/content/10-webhook.md index dab6104f..2824e192 100644 --- a/build/docs/content/10-webhook.md +++ b/build/docs/content/10-webhook.md @@ -128,4 +128,15 @@ $ curl --request POST \ ### PHP -// TODO \ No newline at end of file +```php +use TheCodingMachine\Gotenberg\Client; +use TheCodingMachine\Gotenberg\DocumentFactory; +use TheCodingMachine\Gotenberg\HTMLRequest; + +$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); +$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$request = new HTMLRequest($index); +$request->setWebhookURL('http://myapp.com/webhook/'); +$request->addWebhookURLHTTPHeader('Your-Header', 'Foo'); +$resp = $client->post($request); +``` \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index a762b4a3..63fe13fe 100755 --- a/docs/index.html +++ b/docs/index.html @@ -233,7 +233,7 @@ Gotenberg API is available at http://localhost:3
$ composer require php-http/guzzle6-adapter
 
-

Then the PHP client:

+

Then the PHP client:

$ composer require thecodingmachine/gotenberg-php-client
 
@@ -474,7 +474,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -569,7 +569,7 @@ $footer = DocumentFactory::makeFromPath('footer.html', 'footer.html& $request = new HTMLRequest($index); $request->setHeader($header); $request->setFooter($footer); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -665,7 +665,7 @@ $assets = [ ]; $request = new HTMLRequest($index); $request->setAssets($assets); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -731,7 +731,7 @@ $request = new HTMLRequest($index); $request->setPaperSize(Request::A4); $request->setMargins(Request::NO_MARGINS); $request->setLandscape(true); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -787,7 +787,7 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\ $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); $request->setWaitDelay(5.5); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -846,7 +846,7 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\ $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); $request->setGoogleChromeRpccBufferSize(1048576); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -912,7 +912,7 @@ use TheCodingMachine\Gotenberg\URLRequest; $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); $request = new URLRequest('https://google.com'); $request->setMargins(Request::NO_MARGINS); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -955,7 +955,15 @@ canonical key for accept-encoding is Accept-Encoding.< PHP -

// TODO

+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\URLRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$request = new URLRequest('https://google.com');
+$request->addRemoteURLHTTPHeader('Your-Header', 'Foo')
+$dest = 'result.pdf';
+$client->store($request, $dest);
+
@@ -1030,7 +1038,7 @@ $markdowns = [ DocumentFactory::makeFromPath('file.md', 'file.md'), ]; $request = new MarkdownRequest($index, $markdowns); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -1111,7 +1119,7 @@ $files = [ DocumentFactory::makeFromPath('document2.docx', 'document2.docx'), ]; $request = new OfficeRequest($files); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -1164,7 +1172,7 @@ $files = [ ]; $request = new OfficeRequest($files); $request->setLandscape(true); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -1229,7 +1237,7 @@ $files = [ DocumentFactory::makeFromPath('file2.pdf', 'file2.pdf'), ]; $request = new MergeRequest($files); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -1292,7 +1300,7 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\ $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); $request->setWaitTimeout(2.5); -$dest = "result.pdf"; +$dest = 'result.pdf'; $client->store($request, $dest); @@ -1449,7 +1457,17 @@ canonical key for accept-encoding is Accept-Encoding.< PHP -

// TODO

+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$request = new HTMLRequest($index);
+$request->setWebhookURL('http://myapp.com/webhook/');
+$request->addWebhookURLHTTPHeader('Your-Header', 'Foo');
+$resp = $client->post($request);
+
diff --git a/internal/app/xhttp/handler.go b/internal/app/xhttp/handler.go index 07959870..e15f6443 100644 --- a/internal/app/xhttp/handler.go +++ b/internal/app/xhttp/handler.go @@ -138,7 +138,7 @@ func urlHandler(c echo.Context) error { if err != nil { return err } - opts.CustomHeaders = resource.RemoteURLCustomHeaders(r) + opts.CustomHTTPHeaders = resource.RemoteURLCustomHTTPHeaders(r) if !r.HasArg(resource.RemoteURLArgKey) { return xerror.Invalid( op, @@ -338,14 +338,14 @@ func convertAsync(ctx context.Context, p printer.Printer, filename, fpath string } req.Header.Set(echo.HeaderContentType, "application/pdf") // set custom headers (if any). - customHeaders := resource.WebhookURLCustomHeaders(r) + customHeaders := resource.WebhookURLCustomHTTPHeaders(r) if len(customHeaders) > 0 { for key, value := range customHeaders { req.Header.Set(key, value) - logger.DebugfOp(op, "set '%s' to custom header '%s'", value, key) + logger.DebugfOp(op, "set '%s' to custom HTTP header '%s'", value, key) } } else { - logger.DebugOp(op, "skipping custom headers as none have been provided...") + logger.DebugOp(op, "skipping custom HTTP headers as none have been provided...") } // send the result file. logger.DebugfOp( diff --git a/internal/app/xhttp/handler_test.go b/internal/app/xhttp/handler_test.go index 792569ad..7e141d53 100644 --- a/internal/app/xhttp/handler_test.go +++ b/internal/app/xhttp/handler_test.go @@ -582,7 +582,7 @@ func TestOfficeHandler(t *testing.T) { func TestWebhook(t *testing.T) { customHeaderRealKey := http.CanonicalHeaderKey("MyCustomHeader") - customHeaderKey := fmt.Sprintf("%s%s", resource.WebhookURLCustomHeaderCanonicalBaseKey, customHeaderRealKey) + customHeaderKey := fmt.Sprintf("%s%s", resource.WebhookURLCustomHTTPHeaderCanonicalBaseKey, customHeaderRealKey) customHeaderValue := "foo" status := make(chan error, 2) rcv := echo.New() diff --git a/internal/app/xhttp/pkg/context/context.go b/internal/app/xhttp/pkg/context/context.go index 41f430fb..b8e0b892 100644 --- a/internal/app/xhttp/pkg/context/context.go +++ b/internal/app/xhttp/pkg/context/context.go @@ -80,7 +80,7 @@ func (ctx *Context) WithResource(directoryName string) error { } // retrieve custom headers from request. for key, value := range ctx.Request().Header { - r.WithCustomHeader(key, value[0]) + r.WithCustomHTTPHeader(key, value[0]) } // retrieve form values from request. for _, key := range resource.ArgKeys() { diff --git a/internal/app/xhttp/pkg/resource/header.go b/internal/app/xhttp/pkg/resource/header.go index 9a9745d7..fa4c8814 100644 --- a/internal/app/xhttp/pkg/resource/header.go +++ b/internal/app/xhttp/pkg/resource/header.go @@ -5,15 +5,15 @@ import ( ) const ( - // RemoteURLCustomHeaderCanonicalBaseKey is the base key + // RemoteURLCustomHTTPHeaderCanonicalBaseKey is the base key // of custom headers send to the remote URL. - RemoteURLCustomHeaderCanonicalBaseKey string = "Gotenberg-Remoteurl-" - // WebhookURLCustomHeaderCanonicalBaseKey is the base key + RemoteURLCustomHTTPHeaderCanonicalBaseKey string = "Gotenberg-Remoteurl-" + // WebhookURLCustomHTTPHeaderCanonicalBaseKey is the base key // of custom headers send to the webhook URL. - WebhookURLCustomHeaderCanonicalBaseKey string = "Gotenberg-Webhookurl-" + WebhookURLCustomHTTPHeaderCanonicalBaseKey string = "Gotenberg-Webhookurl-" ) -func fetchCustomHeaders(r Resource, baseKey string) map[string]string { +func fetchCustomHTTPHeaders(r Resource, baseKey string) map[string]string { customHeaders := make(map[string]string) for key, value := range r.customHeaders { if strings.Contains(key, baseKey) { @@ -24,14 +24,14 @@ func fetchCustomHeaders(r Resource, baseKey string) map[string]string { return customHeaders } -// RemoteURLCustomHeaders is a helper for retrieving +// RemoteURLCustomHTTPHeaders is a helper for retrieving // the custom headers for the URL conversion. -func RemoteURLCustomHeaders(r Resource) map[string]string { - return fetchCustomHeaders(r, RemoteURLCustomHeaderCanonicalBaseKey) +func RemoteURLCustomHTTPHeaders(r Resource) map[string]string { + return fetchCustomHTTPHeaders(r, RemoteURLCustomHTTPHeaderCanonicalBaseKey) } -// WebhookURLCustomHeaders is a helper for retrieving +// WebhookURLCustomHTTPHeaders is a helper for retrieving // the custom headers for the webhook URL. -func WebhookURLCustomHeaders(r Resource) map[string]string { - return fetchCustomHeaders(r, WebhookURLCustomHeaderCanonicalBaseKey) +func WebhookURLCustomHTTPHeaders(r Resource) map[string]string { + return fetchCustomHTTPHeaders(r, WebhookURLCustomHTTPHeaderCanonicalBaseKey) } diff --git a/internal/app/xhttp/pkg/resource/header_test.go b/internal/app/xhttp/pkg/resource/header_test.go index 5f9856ee..35a944f8 100644 --- a/internal/app/xhttp/pkg/resource/header_test.go +++ b/internal/app/xhttp/pkg/resource/header_test.go @@ -17,16 +17,16 @@ func TestRemoteURLCustomHeaders(t *testing.T) { // should find the custom header. customHeaderValue := "bar" customHeaderCanonicalRealKey := "Foo" - customHeaderCanonicalKey := http.CanonicalHeaderKey(fmt.Sprintf("%s%s", RemoteURLCustomHeaderCanonicalBaseKey, customHeaderCanonicalRealKey)) - r.WithCustomHeader(customHeaderCanonicalKey, customHeaderValue) - r.WithCustomHeader("Bar", "Bar") + customHeaderCanonicalKey := http.CanonicalHeaderKey(fmt.Sprintf("%s%s", RemoteURLCustomHTTPHeaderCanonicalBaseKey, customHeaderCanonicalRealKey)) + r.WithCustomHTTPHeader(customHeaderCanonicalKey, customHeaderValue) + r.WithCustomHTTPHeader("Bar", "Bar") expected := map[string]string{ customHeaderCanonicalRealKey: customHeaderValue, } notExpected := map[string]string{ customHeaderCanonicalKey: customHeaderValue, } - v := RemoteURLCustomHeaders(r) + v := RemoteURLCustomHTTPHeaders(r) assert.Equal(t, expected, v) assert.NotEqual(t, notExpected, v) } @@ -39,16 +39,16 @@ func TestWebhookURLCustomHeaders(t *testing.T) { // should find the custom header. customHeaderValue := "bar" customHeaderCanonicalRealKey := "Foo" - customHeaderCanonicalKey := http.CanonicalHeaderKey(fmt.Sprintf("%s%s", WebhookURLCustomHeaderCanonicalBaseKey, customHeaderCanonicalRealKey)) - r.WithCustomHeader(customHeaderCanonicalKey, customHeaderValue) - r.WithCustomHeader("Bar", "Bar") + customHeaderCanonicalKey := http.CanonicalHeaderKey(fmt.Sprintf("%s%s", WebhookURLCustomHTTPHeaderCanonicalBaseKey, customHeaderCanonicalRealKey)) + r.WithCustomHTTPHeader(customHeaderCanonicalKey, customHeaderValue) + r.WithCustomHTTPHeader("Bar", "Bar") expected := map[string]string{ customHeaderCanonicalRealKey: customHeaderValue, } notExpected := map[string]string{ customHeaderCanonicalKey: customHeaderValue, } - v := WebhookURLCustomHeaders(r) + v := WebhookURLCustomHTTPHeaders(r) assert.Equal(t, expected, v) assert.NotEqual(t, notExpected, v) } diff --git a/internal/app/xhttp/pkg/resource/resource.go b/internal/app/xhttp/pkg/resource/resource.go index 29d1241d..3a983f18 100644 --- a/internal/app/xhttp/pkg/resource/resource.go +++ b/internal/app/xhttp/pkg/resource/resource.go @@ -75,19 +75,19 @@ func (r Resource) Close() error { return nil } -// WithCustomHeader add a new custom header to the Resource. +// WithCustomHTTPHeader add a new custom header to the Resource. // Given key should be in canonical format. -func (r *Resource) WithCustomHeader(key string, value string) { - const op string = "resource.Resource.WithCustomHeader" +func (r *Resource) WithCustomHTTPHeader(key string, value string) { + const op string = "resource.Resource.WithCustomHTTPHeader" // should already be in canonical format. canonicalKey := http.CanonicalHeaderKey(key) - if strings.Contains(canonicalKey, RemoteURLCustomHeaderCanonicalBaseKey) || - strings.Contains(canonicalKey, WebhookURLCustomHeaderCanonicalBaseKey) { + if strings.Contains(canonicalKey, RemoteURLCustomHTTPHeaderCanonicalBaseKey) || + strings.Contains(canonicalKey, WebhookURLCustomHTTPHeaderCanonicalBaseKey) { r.customHeaders[canonicalKey] = value - r.logger.DebugfOp(op, "added '%s' with value '%s' to resource custom headers", canonicalKey, value) + r.logger.DebugfOp(op, "added '%s' with value '%s' to resource custom HTTP headers", canonicalKey, value) return } - r.logger.DebugfOp(op, "skipping '%s' as it is not a custom header...", canonicalKey) + r.logger.DebugfOp(op, "skipping '%s' as it is not a custom HTTP header...", canonicalKey) } // WithArg add a new argument to the Resource. diff --git a/internal/pkg/printer/chrome.go b/internal/pkg/printer/chrome.go index dce45a05..71e16b32 100644 --- a/internal/pkg/printer/chrome.go +++ b/internal/pkg/printer/chrome.go @@ -31,19 +31,19 @@ type chromePrinter struct { // ChromePrinterOptions helps customizing the // Google Chrome Printer behaviour. type ChromePrinterOptions struct { - WaitTimeout float64 - WaitDelay float64 - HeaderHTML string - FooterHTML string - PaperWidth float64 - PaperHeight float64 - MarginTop float64 - MarginBottom float64 - MarginLeft float64 - MarginRight float64 - Landscape bool - RpccBufferSize int64 - CustomHeaders map[string]string + WaitTimeout float64 + WaitDelay float64 + HeaderHTML string + FooterHTML string + PaperWidth float64 + PaperHeight float64 + MarginTop float64 + MarginBottom float64 + MarginLeft float64 + MarginRight float64 + Landscape bool + RpccBufferSize int64 + CustomHTTPHeaders map[string]string } // DefaultChromePrinterOptions returns the default @@ -51,19 +51,19 @@ type ChromePrinterOptions struct { func DefaultChromePrinterOptions(config conf.Config) ChromePrinterOptions { const defaultHeaderFooterHTML string = "" return ChromePrinterOptions{ - WaitTimeout: config.DefaultWaitTimeout(), - WaitDelay: 0.0, - HeaderHTML: defaultHeaderFooterHTML, - FooterHTML: defaultHeaderFooterHTML, - PaperWidth: 8.27, - PaperHeight: 11.7, - MarginTop: 1.0, - MarginBottom: 1.0, - MarginLeft: 1.0, - MarginRight: 1.0, - Landscape: false, - RpccBufferSize: config.DefaultGoogleChromeRpccBufferSize(), - CustomHeaders: make(map[string]string), + WaitTimeout: config.DefaultWaitTimeout(), + WaitDelay: 0.0, + HeaderHTML: defaultHeaderFooterHTML, + FooterHTML: defaultHeaderFooterHTML, + PaperWidth: 8.27, + PaperHeight: 11.7, + MarginTop: 1.0, + MarginBottom: 1.0, + MarginLeft: 1.0, + MarginRight: 1.0, + Landscape: false, + RpccBufferSize: config.DefaultGoogleChromeRpccBufferSize(), + CustomHTTPHeaders: make(map[string]string), } } @@ -148,7 +148,7 @@ func (p chromePrinter) Print(destination string) error { return err } // add custom headers (if any). - if err := p.setCustomHeaders(ctx, targetClient); err != nil { + if err := p.setCustomHTTPHeaders(ctx, targetClient); err != nil { return err } // listen for all events. @@ -254,18 +254,18 @@ func (p chromePrinter) enableEvents(ctx context.Context, client *cdp.Client) err return nil } -func (p chromePrinter) setCustomHeaders(ctx context.Context, client *cdp.Client) error { - const op string = "printer.chromePrinter.setCustomHeaders" +func (p chromePrinter) setCustomHTTPHeaders(ctx context.Context, client *cdp.Client) error { + const op string = "printer.chromePrinter.setCustomHTTPHeaders" resolver := func() error { - if len(p.opts.CustomHeaders) == 0 { - p.logger.DebugOp(op, "skipping custom headers as none have been provided...") + if len(p.opts.CustomHTTPHeaders) == 0 { + p.logger.DebugOp(op, "skipping custom HTTP headers as none have been provided...") return nil } customHeaders := make(map[string]string) // useless but for the logs. - for key, value := range p.opts.CustomHeaders { + for key, value := range p.opts.CustomHTTPHeaders { customHeaders[key] = value - p.logger.DebugfOp(op, "set '%s' to custom header '%s'", value, key) + p.logger.DebugfOp(op, "set '%s' to custom HTTP header '%s'", value, key) } b, err := json.Marshal(customHeaders) if err != nil {