Accept-Encoding is now toggleable and can also be defined in Custom Headers when turned off.

This commit is contained in:
ruri
2019-05-29 13:32:37 +02:00
parent be1bbc76c8
commit 59a421876d
5 changed files with 16 additions and 3 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -271,7 +271,7 @@ KEYCHECK BanOnToCheck=False
This will spawn and execute a Request Block.
Syntax (expanded for readability):
REQUEST METHOD "URL" [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeContent?]
REQUEST METHOD "URL" [AcceptEncoding?] [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeContent?]
[STANDARD / MULTIPART / BASICAUTH]
[CONTENT "postdata"]
[CONTENTTYPE "ctype"]
@@ -25,17 +25,24 @@
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<!-- Row 1 -->
<DockPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0">
<Label Content="Method:"/>
<ComboBox x:Name="methodCombobox" SelectionChanged="methodCombobox_SelectionChanged"/>
</DockPanel>
<CheckBox Grid.Column="2" Grid.Row="0" Content="Auto Redirect" IsChecked="{Binding AutoRedirect}" VerticalContentAlignment="Center" />
<!-- Row 2 -->
<CheckBox Grid.Column="0" Grid.Row="1" Content="Read Resp. Source" IsChecked="{Binding ReadResponseSource}" VerticalContentAlignment="Center" />
<CheckBox Grid.Column="1" Grid.Row="1" Content="Parse GET Query" IsChecked="{Binding ParseQuery}" VerticalContentAlignment="Center"/>
<CheckBox Grid.Column="2" Grid.Row="1" Content="Encode Content" IsChecked="{Binding EncodeContent}" VerticalContentAlignment="Center"/>
<!-- Row 3 -->
<CheckBox Grid.Column="0" Grid.Row="2" Content="Accept-Encoding" IsChecked="{Binding AcceptEncoding}" VerticalContentAlignment="Center"/>
</Grid>
<DockPanel Margin="0 5 0 0">
+1 -1
View File
@@ -10,7 +10,7 @@ KEYCHECK [BanOn4XX?] [BanOnToCheck?]
]*
</item>
<item name="REQUEST">
REQUEST METHOD "URL" [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeContent?]
REQUEST METHOD "URL" [AcceptEncoding?] [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeContent?]
[STANDARD / MULTIPART / BASICAUTH]
[CONTENT "postdata"]
[CONTENTTYPE "ctype"]
+7 -1
View File
@@ -111,6 +111,10 @@ namespace RuriLib
/// <summary>Whether to URL encode the content before sending it.</summary>
public bool EncodeContent { get { return encodeContent; } set { encodeContent = value; OnPropertyChanged(); } }
private bool acceptEncoding = true;
/// <summary>Whether to automatically generate an Accept-Encoding header.</summary>
public bool AcceptEncoding { get { return acceptEncoding; } set { acceptEncoding = value; OnPropertyChanged(); } }
// Multipart
private string multipartBoundary = "";
/// <summary>The boundary that separates multipart contents.</summary>
@@ -253,6 +257,7 @@ namespace RuriLib
.Token("REQUEST")
.Token(Method)
.Literal(Url)
.Boolean(AcceptEncoding, "AcceptEncoding")
.Boolean(AutoRedirect, "AutoRedirect")
.Boolean(ReadResponseSource, "ReadResponseSource")
.Boolean(ParseQuery, "ParseQuery")
@@ -346,7 +351,7 @@ namespace RuriLib
var timeout = data.GlobalSettings.General.RequestTimeout * 1000;
request.IgnoreProtocolErrors = true;
request.AllowAutoRedirect = autoRedirect;
request.EnableEncodingContent = true;
request.EnableEncodingContent = acceptEncoding;
request.ReadWriteTimeout = timeout;
request.ConnectTimeout = timeout;
request.KeepAlive = true;
@@ -449,6 +454,7 @@ namespace RuriLib
var val = ReplaceValues(header.Value, data);
if (replacedKey == "contenttype" && content != null) { continue; } // Disregard additional Content-Type headers
if (replacedKey == "acceptencoding" && acceptEncoding) { continue; } // Disregard additional Accept-Encoding headers
// else if (fixedNames.Contains(replacedKey)) request.AddHeader((HttpHeader)Enum.Parse(typeof(HttpHeader), replacedKey, true), val);
else request.AddHeader(key, val);