Changeset 30015c1 for apps


Ignore:
Timestamp:
Feb 1, 2019 1:49:13 PM (16 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
175ea0f0
Parents:
4f84550
Message:

i2ptunnel: Handle PUT like POST

Location:
apps/i2ptunnel/java/src/net/i2p/i2ptunnel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java

    r4f84550 r30015c1  
    12801280            // This also prevents the not-found error page from looking bad
    12811281            // Syndie can't handle a redirect of a POST
    1282             if(ahelperPresent && !"POST".equals(method)) {
     1282            if (ahelperPresent && !"POST".equals(method) && !"PUT".equals(method)) {
    12831283                String uri = targetRequest;
    12841284                if(_log.shouldLog(Log.DEBUG)) {
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java

    r4f84550 r30015c1  
    231231                long px = 1000L * getIntOption(OPT_POST_TOTAL_BAN_TIME, DEFAULT_POST_TOTAL_BAN_TIME);
    232232                if (_postThrottler == null)
    233                     _postThrottler = new ConnThrottler(pp, pt, pw, pb, px, "POST", _log);
     233                    _postThrottler = new ConnThrottler(pp, pt, pw, pb, px, "POST/PUT", _log);
    234234                else
    235235                    _postThrottler.updateLimits(pp, pt, pw, pb, px);
     
    482482            if (_postThrottler != null &&
    483483                command.length() >= 5 &&
    484                 command.substring(0, 5).toUpperCase(Locale.US).equals("POST ")) {
     484                (command.substring(0, 5).toUpperCase(Locale.US).equals("POST ") ||
     485                 command.substring(0, 4).toUpperCase(Locale.US).equals("PUT "))) {
    485486                if (_postThrottler.shouldThrottle(peerHash)) {
    486487                    if (_log.shouldLog(Log.WARN))
    487                         _log.warn("Refusing POST since peer is throttled: " + peerB32);
     488                        _log.warn("Refusing POST/PUT since peer is throttled: " + peerB32);
    488489                    try {
    489490                        // Send a 429, so the user doesn't get an HTTP Proxy error message
     
    642643                serverout.write(DataHelper.getUTF8(_headers));
    643644                browserin = _browser.getInputStream();
    644                 // Don't spin off a thread for this except for POSTs
     645                // Don't spin off a thread for this except for POSTs and PUTs
     646                // TODO Upgrade:
    645647                // beware interference with Shoutcast, etc.?
    646648                if ((!(_headers.startsWith("GET ") || _headers.startsWith("HEAD "))) ||
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java

    r4f84550 r30015c1  
    255255   
    256256    private static final byte[] POST = { 'P', 'O', 'S', 'T', ' ' };
     257    private static final byte[] PUT = { 'P', 'U', 'T', ' ' };
    257258
    258259    @Override
     
    290291                        // Don't flush if POST, so we can get POST data into the initial packet
    291292                        if (initialI2PData.length < 5 ||
    292                             !DataHelper.eq(POST, 0, initialI2PData, 0, 5))
     293                            !(DataHelper.eq(POST, 0, initialI2PData, 0, 5) ||
     294                              DataHelper.eq(PUT, 0, initialI2PData, 0, 4)))
    293295                            i2pout.flush();
    294296                    }
Note: See TracChangeset for help on using the changeset viewer.