www-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

www/server/source/linc linc.py


From: Pavel Kharitonov
Subject: www/server/source/linc linc.py
Date: Sat, 29 Jun 2013 07:32:12 +0000

CVSROOT:        /web/www
Module name:    www
Changes by:     Pavel Kharitonov <ineiev>       13/06/29 07:32:12

Modified files:
        server/source/linc: linc.py 

Log message:
        (get_http_linc_error): Minor rearrangement.
        (socket_read): Read up to end of headers when possible.

CVSWeb URLs:
http://web.cvs.savannah.gnu.org/viewcvs/www/server/source/linc/linc.py?cvsroot=www&r1=1.17&r2=1.18

Patches:
Index: linc.py
===================================================================
RCS file: /web/www/www/server/source/linc/linc.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- linc.py     25 May 2013 17:28:27 -0000      1.17
+++ linc.py     29 Jun 2013 07:32:09 -0000      1.18
@@ -18,7 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-LINC_VERSION = 'LINC 0.13'
+LINC_VERSION = 'LINC 0.14'
 USAGE = \
 '''Usage: %prog [options] [BASE_DIRECTORY]
 Check links in HTML files from BASE_DIRECTORY.'''
@@ -189,13 +189,11 @@
        socketfd.send( 'GET ' + resource + ' HTTP/1.1\r\nHost: ' \
                      + hostname + '\r\n' + ADDITIONAL_HTTP_HEADERS + '\r\n' )
 
-       webpage = socket_read( socketfd )
-       if webpage == None:
+       webpage = socket_read (socketfd)
                socketfd.close()
+       if webpage == None:
                return 'couldn\'t read from socket'
 
-       socketfd.close()
-
        end_of_headers = webpage.find('\r\n\r\n')
        if end_of_headers == -1:
                report(1, 'No end of headers found on webpage (link ' \
@@ -432,10 +430,15 @@
                return None
        return socketfd
 
-def socket_read( socketfd ):
+def socket_read (socketfd):
        output = ''
+       max_header_len = 2048
+       while output.find('\r\n\r\n') == -1:
        try:
-               output = socketfd.recv( 2048 )
+                       buf = socketfd.recv (max_header_len)
+                       output += buf
+                       if len (buf) == 0 or len (output) >= max_header_len:
+                               break
        except socket.error, message:
                return None
        return output



reply via email to

[Prev in Thread] Current Thread [Next in Thread]