Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
python-nexlibs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
python-nexlibs
Commits
81384c5c
Commit
81384c5c
authored
Oct 26, 2016
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update webutils
parent
b461ab22
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
webutils.py
nexlibs/utils/webutils.py
+28
-6
No files found.
nexlibs/utils/webutils.py
View file @
81384c5c
...
...
@@ -73,6 +73,7 @@ class HTTPPageGetter(client.HTTPPageGetter):
rectimeout
=
15
checkTimeout
=
False
expect100
=
False
received100
=
False
def
sendCommand
(
self
,
command
,
path
):
version
=
b
' HTTP/1.0
\r\n
'
...
...
@@ -90,6 +91,7 @@ class HTTPPageGetter(client.HTTPPageGetter):
return
client
.
HTTPPageGetter
.
rawDataReceived
(
self
,
*
args
,
**
kwargs
)
def
connectionMade
(
self
,
*
args
,
**
kwargs
):
self
.
lastrec
=
time
.
time
()
if
self
.
checkTimeout
:
try
:
...
...
@@ -102,8 +104,6 @@ class HTTPPageGetter(client.HTTPPageGetter):
auth
=
"Basic "
+
base64
.
encodestring
(
cred
)
.
replace
(
'
\012
'
,
''
)
#self.sendHeader('Authorization', auth)
self
.
factory
.
headers
[
'Authorization'
]
=
auth
if
self
.
expect100
:
self
.
factory
.
headers
[
'Expect'
]
=
'100-continue'
self
.
checkTimeout
=
task
.
LoopingCall
(
self
.
timeoutCheck
)
self
.
checkTimeout
.
start
(
1
)
method
=
getattr
(
self
.
factory
,
'method'
,
b
'GET'
)
...
...
@@ -116,14 +116,15 @@ class HTTPPageGetter(client.HTTPPageGetter):
host
=
self
.
factory
.
host
self
.
sendHeader
(
b
'Host'
,
self
.
factory
.
headers
.
get
(
b
"host"
,
host
))
self
.
sendHeader
(
b
'User-Agent'
,
self
.
factory
.
agent
)
data
=
getattr
(
self
.
factory
,
'postdata'
,
None
)
if
data
is
not
None
:
self
.
sendHeader
(
b
"Content-Length"
,
intToBytes
(
len
(
data
)))
cookieData
=
[]
contenttypehdr
=
False
for
(
key
,
value
)
in
self
.
factory
.
headers
.
items
():
if
key
.
lower
()
not
in
self
.
_specialHeaders
:
# we calculated it on our own
if
key
.
lower
()
==
'content-type'
:
contenttypehdr
=
(
key
,
value
)
else
:
self
.
sendHeader
(
key
,
value
)
if
key
.
lower
()
==
b
'cookie'
:
cookieData
.
append
(
value
)
...
...
@@ -131,6 +132,17 @@ class HTTPPageGetter(client.HTTPPageGetter):
cookieData
.
append
(
cookie
+
b
'='
+
cookval
)
if
cookieData
:
self
.
sendHeader
(
b
'Cookie'
,
b
'; '
.
join
(
cookieData
))
data
=
getattr
(
self
.
factory
,
'postdata'
,
None
)
if
data
is
not
None
:
self
.
sendHeader
(
b
"Content-Length"
,
intToBytes
(
len
(
data
)))
if
self
.
expect100
:
self
.
sendHeader
(
'Expect'
,
'100-continue'
)
if
contenttypehdr
:
key
,
value
=
contenttypehdr
self
.
sendHeader
(
key
,
value
)
self
.
endHeaders
()
self
.
headers
=
{}
...
...
@@ -159,11 +171,21 @@ class HTTPPageGetter(client.HTTPPageGetter):
except
:
pass
def
lineReceived
(
self
,
line
):
client
.
HTTPPageGetter
.
lineReceived
(
self
,
line
)
if
self
.
expect100
and
self
.
received100
:
self
.
received100
=
False
self
.
setLineMode
()
def
handleStatus_100
(
self
):
self
.
received100
=
True
self
.
firstLine
=
True
self
.
__buffer
=
None
if
self
.
expect100
:
self
.
_writeData
()
else
:
self
.
handleStatus_400
()
self
.
setLineMode
()
def
handleStatus_404
(
self
):
self
.
handleStatusDefault
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment