GithubHelp home page GithubHelp logo

csharp-leaf / leaf.xnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from x-rus/xnet

182.0 182.0 53.0 1.51 MB

HTTP Library. Impoved original xNet.

Home Page: https://github.com/csharp-leaf

C# 100.00%

leaf.xnet's People

Contributors

aidenpearce79 avatar ant0x1 avatar c3ffee avatar extremecodetv avatar fedorus avatar geograph-us avatar grandsilence avatar guzlewski avatar nickolaskrayn avatar rgwork avatar rusildo avatar x-rus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaf.xnet's Issues

Add support for head request

I'm currently working on a project and am using get request to get cookies from some website and I'd like to optimize my code and increase the speed by sending head requests so I was wondering if compatibility for those could be added?

HTTPS redirecting links fails

a GET request fails to get response if sent for a url that has or redirects to "https"
tested as HTTP proxy and SOCKS5 Client, both fails
tested the proxy on firefox and it worked without problems.

Leaf.xNet.HttpRequest.Cookies.**get** returned null.

using Leaf.xNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Poe_StashAndMtx_Dump
{
    class Program
    {
        private const string _cookieAuth = "POESESSID=0781497aaa664ae602890520936f6;";

        private static string Request(string url/*, ref CookieDictionary cookies*/)
        {
            using (var request = new HttpRequest())
            {
                HttpResponse response;
                request.Cookies.Set("POESESSID", "0781497aaa664ae60289936f83c6", ".pathofexile.com", "/");
                //request.Cookies = _cookieAuth;
                request.ConnectTimeout = 30 * 1000;
                request.ReadWriteTimeout = 30 * 1000;
                request.UserAgentRandomize();
                request.AllowAutoRedirect = false;
                request.Referer = "";

                response = request.Get(url);

                //cookies = response.Cookies;

                return response.ToString();
            }
        }
        static void Main(string[] args)
        {
            var accountName = "melirench";
            var league = "Legion";
            var getStash = Request("https://www.pathofexile.com/character-window/get-stash-items?accountName="+ accountName + "&realm=pc&league="+league+"&tabs=1&tabIndex=0&public=false");
        }
    }
}

Чем может быть вызвана проблема?

Async Support

Great library!
But when will you provide async/await support?

Проверка куки без домена

Сабж.
Как можно проверить наличие куки в CookieStorage без домена?

В CookieDictionary можно было использовать ContainsKey(""), и все.

Спасибо.

Multipart

How can i send multipart requests?
Original xNet contains AddField() and AddFile() methods.

how can i do the same things via Leaf.xNet?

MessageBodyLoaded Weird Issue

I don't know if I'm not using this how it's supposed to be used or this is just playing tricks with my mind, but I'm getting a pretty weird bug with the MessageBodyLoaded property of HttpResponse objects. I got a simple code something like this:

HttpRequest httpRequest = new HttpRequest();
HttpResponse httpResponse = null;

try
{
    httpResponse = httpRequest.Get("http://www.google.com");
}
catch { }

bool? bodyLoaded = httpResponse?.MessageBodyLoaded; // This line is giving weird results

Every time I run this code bodyLoaded becomes false, even when MessageBodyLoaded is always true. Now, the weird behavior occurs by that only when stepping over that line on the debugger is that bodyLoaded becomes true. What am I missing here? I'm using the latest version (5.1.76) of Leaf.xNet from nuget.

Как сохранить куки на следующий запрос?

В примерах показан такой код:

using (var request = new HttpRequest()) {
    // Do something
}
// Or
HttpRequest request = null;
try {
    request = new HttpRequest();
    // Do something 
}
catch (HttpException ex) {
    // Http error handling
    // You can use ex.Status or ex.HttpStatusCode for more details.
}
catch (Exception ex) {
	// Unhandled exceptions
}
finally {
    // Cleanup in the end if initialized
    request?.Dispose();
}

Но в таком случае куки на каждый запрос будут чистые куки, т.к request инициализируется по новой, а если эт строчку убрать, то будет утечка памяти?
Как правильно делать несколько запросов что бы сохранялись куки?

Get Response Cookies

is it possible to enumerate the response cookies and get their values like the original xnet

RequestParams

в POST-запросе на сайт нужно передавать несколько параметров с одним именем, но разнами значениями (предполагается конвертирование в массив):
RequestParams["a[]"] = value1;
RequestParams["a[]"] = value2;
RequestParams["a[]"] = value3;
было бы неплохо добавить реализацию в базовый класс

Get response in HttpException

Hey,
if a website returns a 4xx status it will throw a httpexception but i cant get the response
to find out what is wrong with the request.
Is there a solution for it and if not could you add that to the exception?

Regards.

Cookies with dot error

Hello, there is again issue with cookies from domains with dot. Last working version 5.1.55.
Example of domain throwing error: Domain=.retail-mobile-prod

Can we incapsula bypass?

Can we have incapsula bypass same as CloudFlare one? Its same principles just need different cookies :)

New proxy support.

Hello.
How can i use it with IPv6 proxies?
or can you add it, please?

thanks.

Can't use http proxy

When I use http proxy with Leaf.Net it say 400 error
here my code

using (var request = new Leaf.xNet.HttpRequest())
{
request.Proxy = new Leaf.xNet.HttpProxyClient("1.1.1.1", 3128);
string html = request.Get("http://api.ipify.org/").ToString();
}

But I use same http proxy with xNet lib. It by pass very good
Here is my code with xNet

using (var request = new xNet.HttpRequest())
{
request.Proxy = xNet.HttpProxyClient.Parse("1.1.1.1:3128");
string html = request.Get("http://api.ipify.org/").ToString();
> }

How can I fix to make Leaf.xNet use http proxy success?

CloudflareException

Hello, I use the Cloudflare Service from a long time with my website. Overnight, this error happens: "Leaf.xNet.Services.Cloudflare.CloudflareException : 'Превышен лимит попыток обхода Cloudflare'".
How can I fix it?

Same HttpRequest MultiThreaded Throws Error

I'm trying to send multiple Get requests in multi thread but I always get
System.NotSupportedException: 'The Write method cannot be called when another write operation is pending.'

Captchasolver cookies

Is there any way to get the cookie headers you get from solving captcha to keep for future requests?

Convert CookieStorage to/from bytes

I don't really familiar with github, so I will propose here. In some cases very useful function is conversion CookieStorage to/from bytes array. The additional code in CookieStorage.cs looks like:

/// <summary>
/// Сохраняет куки в массив байт.
/// </summary>
// ReSharper disable once UnusedMember.Global
public byte[] ToBytes()
{
    byte[] r;

    using (var ms = new MemoryStream())
    {
        Bf.Serialize(ms, this);
        r = ms.ToArray();
    }

    return r;
}

/// <summary>
/// Загружает <see cref="CookieStorage"/> из массива байт.
/// </summary>
/// <param name="bytes">Массив байт</param>
/// <returns>Вернет <see cref="CookieStorage"/>, который задается в свойстве <see cref="HttpRequest"/> Cookies.</returns>
// ReSharper disable once UnusedMember.Global
public static CookieStorage FromBytes(byte[] bytes)
{
    using(var ms = new MemoryStream(bytes))
        return (CookieStorage)Bf.Deserialize(ms);
}

Will appreciate if you will add this to the next release.

Response Headers.

Hello,

I'm trying to get the request headers because I need them to use on another request, but I can't
The request headers are:

Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-User-Id: 1331605
X-User-Authentication-Token: da7df6fcc9ed4df1af87890ef4a28bf7
Cache-Control: no-cache
X-Request-Id: 0dfd665c-55d2-42b6-b7be-cf9ae34da0c3
X-Runtime: 0.156734
Vary: Origin

I can see them on fiddler but I can't get them on my response.

Proxy connection

Is there any exception thrown when xNet could not connect to a proxy/issue with a proxy?

Request Headers

I'm having some issues when dealing with custom headers for a request. So far I have something like:

httpRequest.KeepTemporaryHeadersOnRedirect = true;
httpRequest.EnableMiddleHeaders = true;

httpRequest.AddHeader("Custom-Header1", "CustomValue1");
httpRequest.AddHeader("Custom-Header2", "CustomValue2");
httpRequest.AddHeader("Custom-Header3", "CustomValue3");

while(true)
    var httpResponse = httpRequest.Post(myUrl, postData, "application/x-www-form-urlencoded; charset=UTF-8");

The issue is that only the first POST request of the loop is using the custom headers set at the beginning of the code. In order for the subsequent requests to include those custom headers as well, I need to explicitly state so every time before the request is made. I've set the KeepTemporaryHeadersOnRedirect and EnableMiddleHeaders but they don't seem to make a difference at all for my problem.
My question is how can I make those temporary headers like permanent without having to set them every single time before every request

How to find a value in source page?

Using Leaf.xNet, we can check if the request is a certain content type with Response.ContentType.ToString(), but how do we do this for a value in the source page?

Thanks.

Update Need For CloudFlare

Hello dear.
cloudflare updated 2 dayes ago! and aded an param is name = "s" in the challenge
please add in your bypass and fix it i waiting for your update.
tnx

Проблема с cookies

Здравствуйте.
Делаю Get запрос к одному сайту и получаю такую ошибку:

1

Я так понимаю ошибка через то что сайт выдает какой то левый формат кукисов.
Пробую еще через свойство DontTrackCookies отключить обработку кукисов так как они мне не нужны, но тоже получаю ошибку:

2

Такая проблема только с этим сайтом, с другими все норм.

HTTP 2.0

Hello.
How can i work with HTTP2.0 ?

Can you add possibility to work with that?

Can't get all the cookies

Hey, I just got a little issue with cookies retrieving. The thing is, I'm sending a GET request to this url in order to get a list of cookies before sending a further POST request and include these cookies on it. The issue is that I'm being only able to get 2 cookies out of 5. These are all the cookies I'm suppossed to get

leaf_issue

But as seen in this other pic I'm only getting 2 out 5

leaf_issue3

Notice that I'm cancelling auto-redirections (even tho the original url doesn't have redirs), So far I don't know what else to try. Is this a bug in the lib or this is just me missing something?
Thanks in advance

URL Rewrite causes POST request failure

when sending a POST request to a URL and it gets a redirect, either HTTP to HTTPS or WWW. to non WWW. or the reverse.
The request don't follow, and just returns empty response.

How can I force https?

How can I force to use https? I have a page that I need to load it with https in other way it doesn't load, If I try in the browser without https doesn't work, and the error is returning me the page without the https

Use Leaf.xNet with https proxy

Hi,

I use your lib to connect with https proxy but have error. This is my code

using (var request = new HttpRequest())
{
request.UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.2 Safari/537.36";

            request.AddHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
            request.AddHeader("Accept-Language", "en-US,en;q=0.9");

            var socksProxy = new HttpProxyClient("123.123.123.123", 443, "user", "pass");
            request.Proxy = socksProxy;

            Html = request.Get("https://whoer.net/").ToString();

}

Have error is
Unable to connect to the HTTP-server 'whoer.net'.

How can I fix it?

Content-Length Exception

Hey,
I want to download a big file, but i can't do this because the content-lentgh type is Integer. I think you must pass the content-length type to long ?

Can't get response headers

Hey, first of all very good library, you've done pretty good improvements to the original xNet. Now, I dunno if I'm just being dumb here, but I'm not being able to get the response headers list. So far when I use:

EnumerateHeaders().Current;

Both Key/Value pair are just null, even tho the headers are correctly retrieved and I can see the values in the private fields in the inspector. Am I missing something?
Thanks in advance.

NO UID SEARCH State error

Im using the original xNet not yours, just want to fully make sure you get that.
Regardless, Have you worked around the weird bug with NO UID SEARCH State error when searching for messages?

This occurs right after you send the tag + UID SEARCH .... command
For some odd reason it always tends to occur with Chinese Emails like yeah.net

IgnoreProtocolErrors - what is it?

Hi!

I sometimes receive error "The error on the client side. Status code: 404". But in browser it's not 404 - it's absolutely 200! With IgnoreProtocolErrors this exception not raises.
So, IgnoreProtocolErrors - what means this option?

Thanks.

Multi Thread Cookies for Same domain (each request to have own cookie saved)

Hello, Are the cookies saved automatically for each domain? So if I make a new HttpRequest does it keep the cookie file from the domain?
Or each new HttpRequest has each own cookies?
I want to have Each request to have their own cookies saved.
Also how can I send json data? Is StringContent good?

Can I use headers like php CURL does as array like
Name: Value, Name: Value

Edit:
Tried to use 2threads with different HttpRequest and Different Proxy. But the only one does login normal the other does not

English version?

I would like to know if there is an english translated version..
It's quite hard to understand it in russian.

Proxy on redirect wont work

URL: http://google.com/ (without https)

var req = new HttpRequest();
req.AllowAutoRedirect = true;
req.UserAgent = Http.ChromeUserAgent();
req.Proxy = HttpProxyClient.Parse("ip:port");
var resp = req.Get("http://google.com/");
MessageBox.Show(resp);

http://prntscr.com/mlzhce

If you add https will work. This happened to other websites where there is any kind of redirects.

Any help ?

Regards

response.ToString() error without proxy

Hello, i got this weird error. I'm trying to load a large webpage (The Content-Length is around 50 000) and when i want to get the source code using response.ToString(), this throw an error:

The weird thing of this issue, is when i use a reverse proxy like Fiddler, it loads directly, but without proxies it won't load.

Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.