Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
Proxy
Commits
04be664f
Commit
04be664f
authored
4 years ago
by
Davide Aprea
Browse files
Options
Downloads
Patches
Plain Diff
add correct charset to http header
parent
feca5f9f
No related branches found
Branches containing commit
No related tags found
1 merge request
!19
Resolve "use multi curl to improve performance"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/HtmlDocument.php
+8
-1
8 additions, 1 deletion
app/HtmlDocument.php
app/Http/Controllers/ProxyController.php
+1
-0
1 addition, 0 deletions
app/Http/Controllers/ProxyController.php
with
9 additions
and
1 deletion
app/HtmlDocument.php
+
8
−
1
View file @
04be664f
...
@@ -8,6 +8,7 @@ class HtmlDocument extends Document
...
@@ -8,6 +8,7 @@ class HtmlDocument extends Document
{
{
private
$htmlString
;
private
$htmlString
;
private
$encoding
;
public
function
__construct
(
$password
,
$baseUrl
,
$htmlString
,
$encoding
)
public
function
__construct
(
$password
,
$baseUrl
,
$htmlString
,
$encoding
)
{
{
...
@@ -30,7 +31,7 @@ class HtmlDocument extends Document
...
@@ -30,7 +31,7 @@ class HtmlDocument extends Document
if
(
$meta
->
hasAttribute
(
"http-equiv"
)
&&
strtolower
(
$meta
->
getAttribute
(
"http-equiv"
))
===
"content-type"
&&
$meta
->
hasAttribute
(
"content"
))
{
if
(
$meta
->
hasAttribute
(
"http-equiv"
)
&&
strtolower
(
$meta
->
getAttribute
(
"http-equiv"
))
===
"content-type"
&&
$meta
->
hasAttribute
(
"content"
))
{
$contentType
=
$meta
->
getAttribute
(
"content"
);
$contentType
=
$meta
->
getAttribute
(
"content"
);
$encoding
=
stripos
(
$contentType
,
"charset="
)
!==
false
?
trim
(
substr
(
$contentType
,
stripos
(
$contentType
,
"charset="
)
+
8
))
:
null
;
$encoding
=
stripos
(
$contentType
,
"charset="
)
!==
false
?
trim
(
substr
(
$contentType
,
stripos
(
$contentType
,
"charset="
)
+
8
))
:
null
;
$
contentE
ncoding
=
rtrim
(
$
contentE
ncoding
,
";"
);
$
e
ncoding
=
rtrim
(
$
e
ncoding
,
";"
);
if
(
$encoding
!==
null
)
{
if
(
$encoding
!==
null
)
{
break
;
break
;
}
}
...
@@ -48,6 +49,7 @@ class HtmlDocument extends Document
...
@@ -48,6 +49,7 @@ class HtmlDocument extends Document
# Default Fallback
# Default Fallback
}
}
if
(
!
empty
(
$encoding
))
{
if
(
!
empty
(
$encoding
))
{
$this
->
encoding
=
$encoding
;
return
mb_convert_encoding
(
$htmlString
,
'HTML-ENTITIES'
,
$encoding
);
return
mb_convert_encoding
(
$htmlString
,
'HTML-ENTITIES'
,
$encoding
);
}
else
{
}
else
{
return
mb_convert_encoding
(
$htmlString
,
'HTML-ENTITIES'
);
return
mb_convert_encoding
(
$htmlString
,
'HTML-ENTITIES'
);
...
@@ -59,6 +61,11 @@ class HtmlDocument extends Document
...
@@ -59,6 +61,11 @@ class HtmlDocument extends Document
return
$this
->
htmlString
;
return
$this
->
htmlString
;
}
}
public
function
getEncoding
()
{
return
$this
->
encoding
;
}
/**
/**
* Function proxifyContent
* Function proxifyContent
* This method parses the given String and Proxifies all Links/Urls in it so it's targetting this Proxy Server
* This method parses the given String and Proxifies all Links/Urls in it so it's targetting this Proxy Server
...
...
This diff is collapsed.
Click to expand it.
app/Http/Controllers/ProxyController.php
+
1
−
0
View file @
04be664f
...
@@ -205,6 +205,7 @@ class ProxyController extends Controller
...
@@ -205,6 +205,7 @@ class ProxyController extends Controller
# It's an html document
# It's an html document
$htmlDocument
=
new
HtmlDocument
(
$password
,
$targetUrl
,
$result
[
"data"
],
$contentEncoding
);
$htmlDocument
=
new
HtmlDocument
(
$password
,
$targetUrl
,
$result
[
"data"
],
$contentEncoding
);
$htmlDocument
->
proxifyContent
();
$htmlDocument
->
proxifyContent
();
$result
[
'header'
][
'content-type'
]
=
$contentType
.
"; charset="
.
$htmlDocument
->
getEncoding
();
$result
[
"data"
]
=
$htmlDocument
->
getResult
();
$result
[
"data"
]
=
$htmlDocument
->
getResult
();
break
;
break
;
case
'application/pdf'
:
case
'application/pdf'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment