How serialized header block is divided? - http2

I'm implementing my own HTTP/2 server. Read through the RFC 7540, a portion of content about HTTP header frame got me confused:
https://www.rfc-editor.org/rfc/rfc7540#section-4.3
Header lists are collections of zero or more header fields. When
transmitted over a connection, a header list is serialized into a
header block using HTTP header compression [COMPRESSION]. The
serialized header block is then divided into one or more octet
sequences, called header block fragments
So in my imagination, the process would look like:
+-------------------+ +-------------------+ +------------------+ +---------+
| Header List | | Header Block | | Block Fragment 1 | -> | Frame 1 |
+-------------------+ +-------------------+ +------------------+ +---------+
| :method = POST | | Header 1 Bin Data | | Block Fragment 2 | -> | Frame 2 |
| :path = /resource | -> | Header 2 Bin Data | -> +------------------+ +---------+
| :scheme = https | | Header 3 Bin Data | | Block Fragment 3 | -> | Frame 3 |
| ..... | | Header 4 Bin ... | +------------------+ +---------+
+-------------------+ +-------------------+ ... ...
But how the serialized header block got divided does not mentioned in the section.
So my question is: Is that possible to separate/divide one HTTP header into multiple Header Block Fragments? For example, part of Header 1 Bin Data is carried by Block Fragment 1, and the rest is carried by Block Fragment 2.
Thank you!

Yes, it is possible to split the bytes corresponding to 1 HTTP header into 2 (or more) frames.
You encode the HTTP headers into bytes via HPACK, so you have now just a byte[].
Let's assume the byte[] has length 23.
You can create a HEADERS frame with flags end_headers=false and put for example 13 of the 23 bytes into it.
Then, you create a CONTINUATION frame with flags end_headers=true and put the remaining 10 bytes into it.
It is completely opaque where you split the byte[].
The important thing is that the HEADERS and CONTINUATION frames must be sent one after the other, with no other frame between them.
The receiving side will see the HEADERS frame with end_headers=false, will extract the 13 bytes and will put them aside, waiting for a CONTINUATION frame.
When the CONTINUATION frame arrives, the receiving side will extract the 10 bytes, concatenate it with the previous 13 to obtain a copy of the original 23 bytes that can now be decoded via HPACK, obtaining the original HTTP headers.

Related

Stop godog from parsing Scenario Outline example data table rows

I am not sure it this is intended to be so, but I am confused by the behavior.
When I have the following Scenario Outline:
Scenario Outline: outline1
Given url
And query parameters <query_params>
When method
Then status is
Examples:
| method | endpoint | query_params | status |
| GET | /endpoint1 | ?a=1&b=1 | 200 |
| GET | /endpoint1 | ?a=1&b=1&c=3 | 200 |
I see the following snippet generated.
func FeatureContext(s *godog.Suite) {
s.Step(^method GET$, methodGET)
s.Step(^query parameters \?a=(\d+)&b=(\d+)$, queryParametersAB)
s.Step(^query parameters \?a=(\d+)&b=(\d+)&c=(\d+)$, queryParametersABC)
}
As you can see 2 lines of "query parameters" produces 2 different functions. Why is godog parsing this text? This is a little different from cucumber gherkin parsing.
One side effect of this is that if I have 100 lines in the data table, I am forced to implement all of them.
Is there a way I can ask godog to not do this parsing?
The solution to the problem is to use double quotes around as given below.
Scenario Outline: outline1
Given url
And query parameters "<query_params>"
When method
Then status is
Examples:
| method | endpoint | query_params | status |
| GET | /endpoint1 | ?a=1&b=1 | 200 |
| GET | /endpoint1 | ?a=1&b=1&c=3 | 200 |
Then the following will be generated:
s.Step(`^query parameters "([^"]*)"$`, queryParameters)

Cucumber - run same feature a number of times depending on records in a database

I have a cucumber feature that checks a website has processed payment files correctly (BACS,SEPA, FPS etc). The first stage of the process is to create the payment files which in-turn create expected result data in a database. This data is then used to validate against the payment processing website.
If I process one file, my feature works perfectly validating the expected results. Where I'm stuck is how I get the feature to run (n) number of times depending on the number of records/files that were originally processed.
I've tried an 'Around' hook using a record count iteration with no joy, can't see how I can fit it into an outline scenario and now think that perhaps a rake task to call the feature might work.
Any ideas would be greatly appreciated.
Here's a sample of the feature:
Feature: Processing SEPA Credit Transfer Files. Same Day Value Payments.
Background:
Given we want to test the "SEPA_Regression" scenario suite
And that we have processed a "SEPA" file from the "LDN" branch
And we plan to use the "ITA1" environment
Then we log in to "OPF" as a "SEPA Department" user
#feature #find_and_check_sepa_interchange #all_rows
Scenario: Receive SEPA Credit Transfer Files for branch
Given that we are on the "Payment Management > Interchanges" page
When I search for our Interchange with the following search parameters:
| Field Name |
| Transport Date From |
| Bank |
| Interchange Reference |
Then I can check the following fields for the given file in the "Interchanges" table:
| Field Name|
| Interchange Reference |
| Transport Date |
| File Name |
| File Format |
| Clearing Participant |
| Status |
| Direction |
| Bank |
When I select the associated "Interchange Id" link
Then the "Interchange Details" page is displayed
Update I've implemented nested steps for the feature so that I can call the database records first and feed each set of records (or at least the row id) into the main feature like so:
Feature
#trial_feature
Scenario: Validate multiple Files
Given we have one or more records in the database to process for the "SEPA_Regression" scenario
Then we can validate each file against the system
Feature steps:
Then(/^we can validate each file against the system$/) do
x = 0
while x <= $interchangeHash.count - 1
$db_row = x
# Get the other sets of data using the file name in the query
id = $interchangeHash[x]['id']
file_name = $interchangeHash[x]['CMS_Unique_Reference_Id']
Background.get_data_for_scenario(scenario, file_name)
steps %{
Given that we are on the "Payment Management > Interchanges" page
When I search for our Interchange with the following search parameters:
| Field Name |
| Transport Date From |
| Bank |
| Interchange Reference |
Then I can check the following fields for the given file in the "Interchanges" table:
| Field Name|
| Interchange Reference |
| Transport Date |
| File Name |
| File Format |
| Clearing Participant |
| Status |
| Direction |
| Bank |
When I select the associated "Interchange Id" link
Then the "Interchange Details" page is displayed
Seems a bit of a 'hack' but it works.
If you have batch processing software, then you should have several Given (setup) steps, 1 When (trigger) step, several Then (criteria) steps.
Given I have these SEPA bills
| sepa bill 1 |
| sepa bill 2 |
And I have these BAC bills
| bac bill 1 |
| bac bill 2 |
When the payments are processed
Then these sepa bills are completed
| sepa bill 1 |
| sepa bill 2 |
And I these bac bills are completed
| bac bill 1 |
| bac bill 2 |
It's simpler, easier to read what is supposed to be done, and can be expanded to more. The works should be done in the step definitions of setting up and verifying.

Looping through a subset of an Oracle Collection

I would like some help with a bit of recursive code I need to traverse a graph stored as a collection in PL/SQL.
---------
|LHS|RHS|
---------
| 1 | 2 |
| 2 | 3 |
| 2 | 4 |
| 3 | 5 |
---------
Assuming 1 is the start node, I would like to be able to find 2-3 and 2-4 without looping through the entire collection to check each LHS. I know one solution is to use a global temporary table instead of a collection, but I would really like to avoid reading and writing to and from disk if at all possible.
Edit: The expected output for the above example would be an XML like this:
<1>
<2>
<3>
<5>
</5>
</3>
<4>
</4>
</2>
</1>
Thanks.

NdisChainBufferAtBack substitution in NDIS 6

I am building a filter driver in NDIS 6. I want to add some data at the back of my NET_BUFFER.
To add data I have allocated an MDL through the NdisAllocateMdl API. Now I want to know, is there any wrapper to add this MDL to the existing MDL chain?
If not, is it correct to make the last MDL's Next pointer to point to my new allocated MDL, as I was able to do so? Also what are the fields in NET_BUFFER I have to change to make it recognize the added MDL?
The actual packet payload of an NET_BUFFER is a subset of the payload of the entire MDL chain. The packet might not start at the beginning of the MDL chain, and the packet might not end at the end of the MDL chain.
Therefore, in the most general case, you'll actually need to remove some MDLs from the end of the NET_BUFFER, before you append your new MDL. Let me give a specific example:
NET_BUFFER
* DataOffset=300 bytes
* DataLength=200 bytes
* MdlChain=[200 bytes]->[200 bytes]->[300 bytes]->[200 bytes]
So in this example, the NET_BUFFER points to an MDL chain with 4 MDLs in it. Let's look at the buffers in ASCII-art:
0 100 200 300 400 500 600 700 800 900
| | | | | | | | | |
[ First MDL ][ Second MDL ][ Third MDL ][ Fourth MDL ]
↑ ↑ [ Packet ] ↑
| | |
| | ↑ ↑ |
| | | | |
MdlChain | DataOffset DataLength End-of-MDL-chain
|
CurrentMdl
As hopefully the diagram illustrates, the actual packet payload is only spread across the second & third MDLs. Both the first & fourth MDLs are completely ignored. So if you want to append data to the packet, you need to:
Remove all MDLs from the end of the MDL chain, where the last byte of the MDL's buffer isn't part of the logical packet buffer. (In the example above, remove both the third & fourth MDLs).
Allocate a new buffer that's big enough to hold your data, plus any actual packet payload you deleted from step #1 above. (In the example, you'd have to allocate an extra 100 bytes, to hold the first 100 bytes from the third MDL.)
Chain your new MDL to the end of the chain.
Increment NET_BUFFER::DataLength.
Give the packet to NDIS.
Here's a diagram of what the packet will look like after finishing step 3:
0 100 200 300 400 500 600 700 800 900
| | | | | | | | | |
[ First MDL ][ Second MDL ][ Your MDL ]
↑ ↑ [ Packet ] ↑
| | |
| | ↑ ↑ |
| | | | |
MdlChain | DataOffset DataLength |
| |
CurrentMdl End-of-MDL-chain
Then after step #4:
0 100 200 300 400 500 600 700 800 900
| | | | | | | | | |
[ First MDL ][ Second MDL ][ Your MDL ]
↑ ↑ [ Packet ]
| |
| | ↑ ↑
| | | |
MdlChain | DataOffset DataLength
| |
CurrentMdl End-of-MDL-chain
When the packet is completed back to your driver, you need to undo the modifications you made earlier:
Decrement DataLength.
Remove the MDL you added.
Free the MDL you added.
Restore the original MDLs you removed.

Oracle reports center aligning the header of a field in a repeating frame

I have a label and a field as in the follwing layout.
________________
| _____ |
| | | |
| |Label| |
| |_____| |
| |
| ____________ |->Outer fixedframe
| | _______ | |
| | | | | |
| | |field| | |
| | |_____| | |
| |__>_______| |
| | |
| -->Inner |
| Horizontally expanding repeating frame
|______________|
I would like to center align the label with respect to the field in the inner repeating frame. For example,
If the repeating frame generates 5 fields, the label needs to be right above the 3rd field.
Is this possible using oracle reports or any alternate layouts?. Any help would be much appreciated
I just got this working with a quick mock-up and here is how I did it:
1) Select the "Anchor" tool from the tool palette and anchor the bottom middle "outline square" (I'm not sure what the technical term for those are but the grab-points on an object where you can resize them) from the label object and connect it to the top middle "outline square" of the horizontal repeating frame.
2) [Optional] Click on the anchor line and check the properties to make sure the Child Edge Type is set to "Bottom", the Child Edge Percent is "50", the Parent Edge Type is "Top", and the Parent Edge Percent is "50".
3) Click on the label and set the Keep With Anchoring Object property to "Yes".
4) Make sure your label is centered over the repeating frame in the Paper Layout view. I noticed that if it is off-centered to start with it will be off-centered by the same amount when run. I ended up making the label the same width as the repeating frame it was over and then set both to a Horizontal Elasticity of "Variable".
I ran this with 5 horizontally repeated objects and then I added a 6th to verify it remained centered and both worked.
Hope that helps and that I didn't miss a step. I'll save the mock-up in case it needs further steps or explanation.

Resources