Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images hosted at a different TCP port on the same host are not included in PDF - patch included #290

Closed
michaelrsweet opened this issue Aug 23, 2016 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@michaelrsweet
Copy link
Owner

Version: 1.8-current
Original reporter: Iain W. Bird

Where a web server hosts sites on multiple ports, if a site on e.g. port 81 includes images or other content from e.g. port 82, then HTTP keepalive prevents disconnect and reconnect to the new port, hence ERR404 is emitted.

The fix is to always reconnect if the port number differs.

Patch included

@michaelrsweet
Copy link
Owner Author

"htmldocimg.txt":

Index: htmldoc/file.c
===================================================================
--- htmldoc/file.c	(revision 1736)
+++ htmldoc/file.c	(working copy)
@@ -96,6 +96,7 @@
 char	cookies[1024] = "";		/* HTTP cookies, if any */
 char	referer_url[HTTP_MAX_VALUE] = "";
 					/* HTTP referer, if any */
+static int last_connport = 0;		/* Port of last connection */ 
 
 
 /*
@@ -364,6 +365,7 @@
  * 'file_find_check()' - Check to see if the specified file or URL exists...
  */
 
+
 static const char *			/* O - Pathname or NULL */
 file_find_check(const char *filename)	/* I - File or URL */
 {
@@ -461,15 +463,22 @@
         strlcpy(connpath, resource, sizeof(connpath));
       }
 
-      if (strcasecmp(httpGetHostname(http, tempname, sizeof(tempname)),
-                     hostname))
+      if (last_connport != connport || (strcasecmp(httpGetHostname(http, tempname, sizeof(tempname)),
+                     hostname)))
       {
+	/*
+	 * Even if the host is the same, we must disconnect if the port is
+	 * different to avoid persisted HTML keepalives.
+	 */
+
+	last_connport = 0;
         httpClose(http);
         http = NULL;
       }
 
       if (http == NULL)
       {
+	last_connport = 0;
         progress_show("Connecting to %s...", connhost);
 
 #ifdef HAVE_SSL
@@ -488,6 +497,10 @@
 	                 "Unable to connect to %s!", connhost);
           return (NULL);
         }
+	else
+	{
+	  last_connport = connport;
+	}
       }
 
       progress_show("Getting %s...", connpath);

@michaelrsweet michaelrsweet added the bug Something isn't working label Mar 3, 2017
@michaelrsweet michaelrsweet added this to the Stable milestone Mar 3, 2017
@michaelrsweet
Copy link
Owner Author

[master 87a317d] Fix a URL referencing bug when the same hostname but a different port was used (Issue #290)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant