Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
da6759a9
Commit
da6759a9
authored
Sep 23, 2018
by
knowledge4igor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring and getting rid of magic number
parent
1a90268a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
16 deletions
+20
-16
include/pistache/http.h
include/pistache/http.h
+15
-0
include/pistache/http_defs.h
include/pistache/http_defs.h
+2
-0
src/client/client.cc
src/client/client.cc
+2
-15
src/common/http_header.cc
src/common/http_header.cc
+1
-1
No files found.
include/pistache/http.h
View file @
da6759a9
...
...
@@ -26,6 +26,7 @@
#include <pistache/peer.h>
#include <pistache/tcp.h>
#include <pistache/transport.h>
#include <pistache/view.h>
namespace
Pistache
{
namespace
Http
{
...
...
@@ -810,5 +811,19 @@ std::shared_ptr<H> make_handler(Args&& ...args) {
return
std
::
make_shared
<
H
>
(
std
::
forward
<
Args
>
(
args
)...);
}
namespace
helpers
{
inline
Address
httpAddr
(
const
StringView
&
view
)
{
auto
const
str
=
view
.
toString
();
auto
const
pos
=
str
.
find
(
':'
);
if
(
pos
==
std
::
string
::
npos
)
{
return
Address
(
std
::
move
(
str
),
HTTP_STANDARD_PORT
);
}
auto
const
host
=
str
.
substr
(
0
,
pos
);
auto
const
port
=
std
::
stoi
(
str
.
substr
(
pos
+
1
));
return
Address
(
std
::
move
(
host
),
port
);
}
}
// namespace helpers
}
// namespace Http
}
// namespace Pistache
include/pistache/http_defs.h
View file @
da6759a9
...
...
@@ -118,6 +118,8 @@ namespace Http {
CHARSET(Utf32-LE, "utf-32le") \
CHARSET(Unicode-11, "unicode-1-1")
const
uint16_t
HTTP_STANDARD_PORT
=
80
;
enum
class
Method
{
#define METHOD(m, _) m,
HTTP_METHODS
...
...
src/client/client.cc
View file @
da6759a9
...
...
@@ -10,6 +10,7 @@
#include <netdb.h>
#include <pistache/client.h>
#include <pistache/http.h>
#include <pistache/stream.h>
...
...
@@ -19,20 +20,6 @@ using namespace Polling;
namespace
Http
{
namespace
{
Address
httpAddr
(
const
StringView
&
view
)
{
auto
str
=
view
.
toString
();
auto
pos
=
str
.
find
(
':'
);
if
(
pos
==
std
::
string
::
npos
)
{
return
Address
(
std
::
move
(
str
),
80
);
}
auto
host
=
str
.
substr
(
0
,
pos
);
auto
port
=
std
::
stoi
(
str
.
substr
(
pos
+
1
));
return
Address
(
std
::
move
(
host
),
port
);
}
}
static
constexpr
const
char
*
UA
=
"pistache/0.1"
;
std
::
pair
<
StringView
,
StringView
>
...
...
@@ -872,7 +859,7 @@ Client::doRequest(
}
if
(
!
conn
->
isConnected
())
{
conn
->
connect
(
httpAddr
(
s
.
first
));
conn
->
connect
(
h
elpers
::
h
ttpAddr
(
s
.
first
));
}
return
conn
->
perform
(
request
,
timeout
,
[
=
]()
{
...
...
src/common/http_header.cc
View file @
da6759a9
...
...
@@ -346,7 +346,7 @@ Host::parse(const std::string& data) {
port_
=
p
;
}
else
{
host_
=
data
;
port_
=
80
;
port_
=
HTTP_STANDARD_PORT
;
}
}
...
...
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