In TWebModule1.WebModule1WebActionItem1Action(), using Request.ContentFields.Values['content'] or any name, I cannot get any values from the POST, but if I use Request.ContentFields.DelimitedText, I will get the values. Where did I go wrong?
This is the values DelimitedText returned:
------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""name""",NEWTEST,------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""content""","{""resolution""",D,",""symbol_type""",stock,",""exchange""",IDX,",""listed_exchange""",IDX,",""symbol""",BBCA,",""short_name""",BBCA,",""legs""",[{\,"symbol\"":\""","BCA\"",\""","ro_symbol\"":\""","BCA\""}]""",id,":2,""name""",NEWTEST,",""description""",,",""charts_symbols""",{\,"1\"":{\""","ymbol\"":\""","BCA\""}}""",is_realtime,":""1""",content,":""{\""","ame\"":\""","EWTEST\"",\""","ayout\"":\""","\"",\""","harts\"":[{\""","anes\"":[{\""","ources\"":[{\""","ype\"":\""","ainSeries\"",\""","d\"":\""","NUxsv\"",\""","tate\"":{\""","tyle\"":8,\""","sdShowDividends\"":true,\""","sdShowSplits\"":true,\""","sdShowEarnings\"":true,\""","sdShowBreaks\"":false,\""","sdFlagSize\"":2,\""","howCountdown\"":false,\""","idAsk\"":{\""","isible\"":false,\""","ineStyle\"":1,\""","ineWidth\"":1,\""","idLineColor\"":\""","2962FF\"",\""","skLineColor\"":\""","F7525F\""},\""","rePostMarket\"":{\""","isible\"":true,\""","ineStyle\"":1,\""","ineWidth\"":1,\""","reMarketColor\"":\""","fb8c00\"",\""","ostMarketColor\"":\""","2962FF\""},\""","ighLowAvgPrice\"":{\""","ighLowPriceLinesVisible\"":false,\""","ighLowPriceLabelsVisible\"":false,\""","verageClosePriceLineVisible\"":false,\""","verageClosePriceLabelVisible\"":false},\""","howInDataWindow\"":true,\""","isible\"":true,\""","howPriceLine\"":true,\""","riceLineWidth\"":1,\""","riceLineColor\"":\""",",\","baseLineColor\"":\""","B2B5BE\"",\""","howPrevClosePriceLine\"":false,\""","revClosePriceLineWidth\"":1,\""","revClosePriceLineColor\"":\""","gba( 85, 85, 85, 1)\"",\""","inTick\"":\""","efault\"",\""","ividendsAdjustment\"":{},\""","ackAdjustment\"":false,\""","ettlementAsClose\"":true,\""","essionId\"":\""","egular\"",\""","essVis\"":false,\""","tatusViewStyle\"":{\""","ontSize\"":17,\""","howExchange\"":true,\""","howInterval\"":true,\""","ymbolTextSource\"":\""","escription\"",\""","howSymbolAsDescription\"":false},\""","andleStyle\"":{\""","pColor\"":\""","53b987\"",\""","ownColor\"":\""","eb4d5c\"",\""","rawWick\"":true,\""","rawBorder\"":true,\""","orderColor\"":\""","378658\"",\""","orderUpColor\"":\""","53b987\"",\""","orderDownColor\"":\""","eb4d5c\"",\""","ickColor\"":\""","737375\"",\""","ickUpColor\"":\""","a9cdd3\"",\""","ickDownColor\"":\""","f5a6ae\"",\""","arColorsOnPrevClose\"":false,\""","rawBody\"":true},\""","ollowCandleStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","rawWick\"":true,\""","rawBorder\"":true,\""","orderColor\"":\""","gba( 55, 134, 88, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","ickColor\"":\""","gba( 115, 115, 117, 1)\"",\""","ickUpColor\"":\""","gba( 169, 220, 195, 1)\"",\""","ickDownColor\"":\""","gba( 245, 166, 174, 1)\"",\""","rawBody\"":true},\""","aStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","rawWick\"":true,\""","rawBorder\"":true,\""","orderColor\"":\""","gba( 55, 134, 88, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","ickColor\"":\""","gba( 115, 115, 117, 1)\"",\""","ickUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ickDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","howRealLastPrice\"":false,\""","arColorsOnPrevClose\"":false,\""","nputs\"":{},\""","nputInfo\"":{},\""","rawBody\"":true},\""","arStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","arColorsOnPrevClose\"":false,\""","ontDrawOpen\"":false,\""","hinBars\"":true},\""","iloStyle\"":{\""","olor\"":\""","2962FF\"",\""","howBorders\"":true,\""","orderColor\"":\""","2962FF\"",\""","howLabels\"":true,\""","abelColor\"":\""","2962FF\"",\""","ontSize\"":7,\""","rawBody\"":true},\""","ineStyle\"":{\""","olor\"":\""","gba( 60, 120, 216, 1)\"",\""","inestyle\"":0,\""","inewidth\"":1,\""","riceSource\"":\""","lose\"",\""","tyleType\"":2},\""","reaStyle\"":{\""","olor1\"":\""","gba( 96, 96, 144, 0.5)\"",\""","olor2\"":\""","gba( 1, 246, 245, 0.5)\"",\""","inecolor\"":\""","gba( 0, 148, 255, 1)\"",\""","inestyle\"":0,\""","inewidth\"":1,\""","riceSource\"":\""","lose\"",\""","ransparency\"":50},\""","enkoStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","orderUpColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","orderDownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","ickUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ickDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","nputs\"":{\""","ource\"":\""","lose\"",\""","ources\"":\""","lose\"",\""","oxSize\"":3,\""","tyle\"":\""","TR\"",\""","trLength\"":14,\""","icks\"":true},\""","nputInfo\"":{\""","ource\"":{\""","ame\"":\""","ource\""},\""","ources\"":{\""","ame\"":\""","ource\""},\""","oxSize\"":{\""","ame\"":\""","ox size\""},\""","tyle\"":{\""","ame\"":\""","tyle\""},\""","trLength\"":{\""","ame\"":\""","TR Length\""},\""","icks\"":{\""","ame\"":\""","icks\""}}},\""","bStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","orderUpColor\"":\""","gba( 83, 185, 135, 1)\"",\""","orderDownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","orderUpColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","orderDownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ource\"":\""","lose\"",\""","b\"":3},\""","nputInfo\"":{\""","ource\"":{\""","ame\"":\""","ource\""},\""","b\"":{\""","ame\"":\""","umber of line\""}}},\""","agiStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ource\"":\""","lose\"",\""","tyle\"":\""","TR\"",\""","trLength\"":14,\""","eversalAmount\"":1},\""","nputInfo\"":{\""","ource\"":{\""","ame\"":\""","ource\""},\""","tyle\"":{\""","ame\"":\""","tyle\""},\""","trLength\"":{\""","ame\"":\""","TR Length\""},\""","eversalAmount\"":{\""","ame\"":\""","eversal amount\""}}},\""","nfStyle\"":{\""","pColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ownColor\"":\""","gba( 255, 77, 92, 1)\"",\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ources\"":\""","lose\"",\""","eversalAmount\"":3,\""","oxSize\"":1,\""","tyle\"":\""","TR\"",\""","trLength\"":14,\""","neStepBackBuilding\"":false},\""","nputInfo\"":{\""","ources\"":{\""","ame\"":\""","ource\""},\""","oxSize\"":{\""","ame\"":\""","ox size\""},\""","eversalAmount\"":{\""","ame\"":\""","eversal amount\""},\""","tyle\"":{\""","ame\"":\""","tyle\""},\""","trLength\"":{\""","ame\"":\""","TR Length\""},\""","neStepBackBuilding\"":{\""","ame\"":\""","ne step back building\""}}},\""","aselineStyle\"":{\""","aselineColor\"":\""","gba( 117, 134, 150, 1)\"",\""","opFillColor1\"":\""","gba( 83, 185, 135, 0.1)\"",\""","opFillColor2\"":\""","gba( 83, 185, 135, 0.1)\"",\""","ottomFillColor1\"":\""","gba( 235, 77, 92, 0.1)\"",\""","ottomFillColor2\"":\""","gba( 235, 77, 92, 0.1)\"",\""","opLineColor\"":\""","gba( 83, 185, 135, 1)\"",\""","ottomLineColor\"":\""","gba( 235, 77, 92, 1)\"",\""","opLineWidth\"":1,\""","ottomLineWidth\"":1,\""","riceSource\"":\""","lose\"",\""","ransparency\"":50,\""","aseLevelPercentage\"":50},\""","angeStyle\"":{\""","pColor\"":\""","22AB94\"",\""","ownColor\"":\""","F7525F\"",\""","hinBars\"":true,\""","pColorProjection\"":\""","gba( 169, 220, 195, 1)\"",\""","ownColorProjection\"":\""","gba( 245, 166, 174, 1)\"",\""","nputs\"":{\""","ange\"":10,\""","hantomBars\"":false},\""","nputInfo\"":{\""","ange\"":{\""","ame\"":\""","ange\""},\""","hantomBars\"":{\""","ame\"":\""","hantom bars\""}}},\""","ilentIntervalChange\"":false,\""","ymbol\"":\""","BCA\"",\""","hortName\"":\""","BCA\"",\""","imeframe\"":\""",",\","onWidget\"":false,\""","nterval\"":\""","\"",\""","nitId\"":null,\""","urrencyId\"":\""","DR\"",\""","howSessions\"":false,\""","riceAxisProperties\"":{\""","utoScale\"":true,\""","utoScaleDisabled\"":false,\""","ockScale\"":false,\""","ercentage\"":false,\""","ercentageDisabled\"":false,\""","og\"":false,\""","ogDisabled\"":false,\""","lignLabels\"":true,\""","sInverted\"":false,\""","ndexedTo100\"":false}},\""","order\"":0,\""","aStyle\"":{\""","tudyId\"":\""","arSetHeikenAshi#tv-basicstudies-60\""},\""","enkoStyle\"":{\""","tudyId\"":\""","arSetRenko#tv-prostudies-40\""},\""","bStyle\"":{\""","tudyId\"":\""","arSetPriceBreak#tv-prostudies-34\""},\""","agiStyle\"":{\""","tudyId\"":\""","arSetKagi#tv-prostudies-34\""},\""","nfStyle\"":{\""","tudyId\"":\""","arSetPnF#tv-prostudies-34\""},\""","angeStyle\"":{\""","tudyId\"":\""","arSetRange#tv-basicstudies-72\""}},{\""","ype\"":\""","tudy_Volume\"",\""","d\"":\""","InSIU\"",\""","tate\"":{\""","tyles\"":{\""","ol\"":{\""","inestyle\"":0,\""","inewidth\"":1,\""","lottype\"":5,\""","rackPrice\"":false,\""","ransparency\"":50,\""","isible\"":true,\""","olor\"":\""","000080\"",\""","istogramBase\"":0,\""","oinPoints\"":false,\""","itle\"":\""","olume\""},\""","ol_ma\"":{\""","inestyle\"":0,\""","inewidth\"":1,\""","lottype\"":0,\""","rackPrice\"":false,\""","ransparency\"":0,\""","isible\"":false,\""","olor\"":\""","2196f3\"",\""","istogramBase\"":0,\""","oinPoints\"":false,\""","itle\"":\""","olume MA\""},\""","moothedMA\"":{\""","inestyle\"":0,\""","inewidth\"":1,\""","lottype\"":0,\""","rackPrice\"":false,\""","ransparency\"":0,\""","isible\"":false,\""","olor\"":\""","2196f3\"",\""","istogramBase\"":0,\""","oinPoints\"":false,\""","itle\"":\""","moothed MA\""}},\""","alettes\"":{\""","olumePalette\"":{\""","olors\"":{\""","\"":{\""","olor\"":\""","F7525F\"",\""","idth\"":1,\""","tyle\"":0,\""","ame\"":\""","alling\""},\""","\"":{\""","olor\"":\""","22AB94\"",\""","idth\"":1,\""","tyle\"":0,\""","ame\"":\""","rowing\""}}}},\""","nputs\"":{\""","howMA\"":false,\""","ength\"":20,\""","ol_prev_close\"":false,\""","ymbol\"":\""",",\","smoothingLine\"":\""","MA\"",\""","moothingLength\"":9},\""","recision\"":\""","efault\"",\""","ands\"":{},\""","rea\"":{},\""","raphics\"":{},\""","howInDataWindow\"":true,\""","isible\"":true,\""","howLegendValues\"":true,\""","howLabelsOnPriceScale\"":true,\""","lots\"":{\""","\"":{\""","d\"":\""","ol\"",\""","ype\"":\""","ine\""},\""","\"":{\""","d\"":\""","olumePalette\"",\""","alette\"":\""","olumePalette\"",\""","arget\"":\""","ol\"",\""","ype\"":\""","olorer\""},\""","\"":{\""","isible\"":true,\""","utureOnly\"":true,\""","reaks\"":{\""","olor\"":\""","gba(85, 85, 85, 1)\"",\""","isible\"":false,\""","tyle\"":2,\""","idth\"":1}},\""","radingProperties\"":{\""","howPositions\"":true,\""","ositionPL\"":{\""","isibility\"":true,\""","isplay\"":0},\""","howOrders\"":true,\""","howExecutions\"":true,\""","howReverse\"":true,\""","orizontalAlignment\"":2,\""","xtendLeft\"":true,\""","ineLength\"":5,\""","ineWidth\"":1,\""","ineStyle\"":2},\""","riceScaleSelectionStrategyName\"":\""","uto\""},\""","ineToolsGroups\"":{\""","roups\"":[]},\""","ersion\"":3,\""","imezone\"":\""","tc/UTC\"",\""","essions\"":{\""","roperties\"":{\""","raphics\"":{\""","ackgrounds\"":{\""","utOfSession\"":{\""","olor\"":\""","2962FF\"",\""","ransparency\"":92,\""","isible\"":false},\""","reMarket\"":{\""","olor\"":\""","FF9800\"",\""","ransparency\"":92,\""","isible\"":false},\""","ostMarket\"":{\""","olor\"":\""","2962FF\"",\""","ransparency\"":92,\""","isible\"":false}},\""","ertlines\"":{\""","essBreaks\"":{\""","olor\"":\""","4985e7\"",\""","tyle\"":2,\""","isible\"":false,\""","idth\"":1}}}}},\""","houldBeSavedEvenIfHidden\"":true,\""","hartId\"":\""","\""}]}""",------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""symbol""",BBCA,------WebKitFormBoundaryHkgxkABfO4DL8g8Q,"Content-Disposition: form-data; name=""resolution""",D,------WebKitFormBoundaryHkgxkABfO4DL8g8Q--
I have been googling the whole web, mostly outdated answer from years ago and I don't find any proper easy way to parse it, but I found my own manual way, please anyone, have a better way to parse please share. thanks.
LBoundary := ExtractHeaderSubItem(Request.ContentType, 'boundary', QuoteHTTP);
tmpstring := Request.Content;
tmpstring := trim(tmpstring);
i := Pos('Content-Disposition: form-data; name="name"', tmpstring);
j := Pos('Content-Disposition: form-data; name="content"', tmpstring);
k := j - i;
tmpstring := (Copy(tmpstring, i, k));
tmpstring := StringReplace(tmpstring, 'Content-Disposition: form-data; name="name"', '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, 'Content-Disposition: form-data; name="content"', '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, '--'+LBoundary, '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, #13#10, '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, #32, '', [rfReplaceAll]);
tmpstring := StringReplace(tmpstring, #9, '', [rfReplaceAll]);
name:= tmpstring;
I am getting List of 8-bit unsigned int from a mic source for each sample rate which looks like this
[61, 251, 199, 251, 56, 252, 138, 252, 211, 252, 18, 253, 91, 253, 194, 253, 25, 254, 54, 254, 19, 254, 190, 253, 80, 253, 249, 252, 233, 252, 46, 253, 180, 253, 54, 254, 136, 254, 157, 254, 110, 254, 38, 254, 208, 253, 117, 253, 68, 253, 57, 253, 83, 253, 163, 253, 20, 254, 151, 254, 51, 255, 215, 255, 105, 0, 207, 0, 246, 0, 249, 0, 10, 1, 64, 1, 162, 1, 4, 2, 64, 2, 97, 2, 111, 2, 110, 2, 89, 2, 40, 2, 241, 1, 199, 1, 178, 1, 192, 1, 241, 1, 45, 2, 77, 2, 70, 2, 45, 2, 36, 2, 83, 2, 176, 2, 21, 3, 121, 3, 229, 3, 87, 4, 185, 4, 225, 4, 197, 4, 129, 4, 26, 4, 150, 3, 7, 3, 128, 2, 55, 2, 65, 2, 134, 2, 223, 2, 25, 3, 41, 3, 28, 3, 255, 2, 234, 2, 240, 2, 25, 3, 62, 3, 92, 3, 146, 3, 219, 3, 65, 4, 149, 4, 164, 4, 130, 4, 51, 4, 195, 3, 69, 3, 164, 2, 244, 1, 75, 1, 187, 0, 81, 0, 240, 255, 135, 255, 19, 255, 155, 254, 64, 254, 22, 254, 58, 254, 146, 254, 217, 254, 248, 254, 215, 254, 144, 254, 92, 254, 84, 254, 141, 254, 229, 254, 39, 255, 96, 255, 170, 255, 248, 255, 69, 0, 117, 0, 128, 0, 137, 0, 131, 0,
so how can I convert this into signed decimal value or someone can guide me to the right path
That depends on what the bytes mean.
Looking at the bytes, every other byte is either very low or very high. That suggests to me that the bytes are really little-endian signed 16-bit values.
In that case, you just need to view them as such. If we assume that the platform is little-endian (most are), you can just do:
List<int> list = ...;
Uint8List bytes = Uint8List.fromList(list); //
Int16List words = Int16List.sublistView(bytes);
Then the words list contains signed 16-bit numbers.
(If the list is already a Uint8List, you can skip the first step.)
If that's not what the bytes mean, you'll have to figure out what they do mean.
Dart int type provide a method to convert from signed to unsigned and from unsigned to signed.
For example:
int a = 16;
int b = 239;
print(a.toSigned(5).toString()); // Print -16
print(b.toSigned(5).toString()); // Print 15
the toSigned method parameter indicate the bit order of the sign bit.
You can get more information here: https://api.flutter.dev/flutter/dart-core/int/toSigned.html
A toUnsigned method exixts too: https://api.flutter.dev/flutter/dart-core/int/toUnsigned.html