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
fafa745e
Commit
fafa745e
authored
Aug 22, 2015
by
Mathieu STEFANI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved Reverter inside Cursor
parent
b0aba763
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
30 deletions
+31
-30
src/http.cc
src/http.cc
+5
-5
src/http.h
src/http.h
+26
-25
No files found.
src/http.cc
View file @
fafa745e
...
...
@@ -89,7 +89,7 @@ namespace Private {
Parser
::
State
Parser
::
RequestLineStep
::
apply
(
Cursor
&
cursor
)
{
Reverter
reverter
(
cursor
);
Cursor
::
Revert
revert
(
cursor
);
auto
tryMatch
=
[
&
](
const
char
*
const
str
)
{
const
size_t
len
=
std
::
strlen
(
str
);
...
...
@@ -165,17 +165,17 @@ namespace Private {
if
(
!
cursor
.
advance
(
2
))
return
State
::
Again
;
revert
er
.
clear
();
revert
.
ignore
();
return
State
::
Next
;
}
Parser
::
State
Parser
::
HeadersStep
::
apply
(
Cursor
&
cursor
)
{
Reverter
reverter
(
cursor
);
Cursor
::
Revert
revert
(
cursor
);
while
(
!
cursor
.
eol
())
{
Reverter
headerReverter
(
cursor
);
Cursor
::
Revert
headerRevert
(
cursor
);
// Read the header name
size_t
start
=
cursor
;
...
...
@@ -205,7 +205,7 @@ namespace Private {
// CRLF
if
(
!
cursor
.
advance
(
2
))
return
State
::
Again
;
headerRevert
er
.
clear
();
headerRevert
.
ignore
();
}
return
Parser
::
State
::
Next
;
...
...
src/http.h
View file @
fafa745e
...
...
@@ -138,6 +138,32 @@ namespace Private {
};
struct
Cursor
{
struct
Revert
{
Revert
(
Cursor
&
cursor
)
:
cursor
(
cursor
)
,
pos
(
cursor
.
value
)
,
active
(
true
)
{
}
void
revert
()
{
cursor
.
value
=
pos
;
}
void
ignore
()
{
active
=
false
;
}
~
Revert
()
{
if
(
active
)
cursor
.
value
=
pos
;
}
Cursor
&
cursor
;
size_t
pos
;
bool
active
;
};
static
constexpr
int
Eof
=
-
1
;
Cursor
(
const
Buffer
&
buffer
,
size_t
initialPos
=
0
)
...
...
@@ -162,31 +188,6 @@ namespace Private {
size_t
value
;
};
struct
Reverter
{
Reverter
(
Cursor
&
cursor
)
:
cursor
(
cursor
)
,
pos
(
cursor
.
value
)
,
active
(
true
)
{
}
void
revert
()
{
cursor
.
value
=
pos
;
}
void
clear
()
{
active
=
false
;
}
~
Reverter
()
{
if
(
active
)
cursor
.
value
=
pos
;
}
Cursor
&
cursor
;
size_t
pos
;
bool
active
;
};
enum
class
State
{
Again
,
Next
,
Done
};
struct
Step
{
...
...
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